math-base-special-round-nearest-even
Round numbers to the nearest even integer with the math-base-special-round-nearest-even library. Ideal for precise numerical computations in JavaScript. 🛠️📊
https://github.com/toyosang/math-base-special-round-nearest-even
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.0%) to scientific vocabulary
Keywords
Repository
Round numbers to the nearest even integer with the math-base-special-round-nearest-even library. Ideal for precise numerical computations in JavaScript. 🛠️📊
Basic Info
- Host: GitHub
- Owner: toyosang
- License: apache-2.0
- Language: Python
- Default Branch: main
- Size: 55.7 KB
Statistics
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Round Nearest Even: A JavaScript Math Utility for Precision 🎯
Overview
This repository provides a simple and efficient way to round double-precision floating-point numbers to the nearest integer. When ties occur, it rounds to the nearest even integer, ensuring consistent and predictable results.
For the latest version, please check the Releases section.
Table of Contents
Features
- Rounds numbers to the nearest integer.
- Handles ties by rounding to the nearest even integer.
- Lightweight and easy to integrate into any JavaScript project.
- Works seamlessly with Node.js and browser environments.
Installation
To install the package, use npm:
bash
npm install math-base-special-round-nearest-even
Alternatively, you can clone the repository directly:
bash
git clone https://github.com/toyosang/math-base-special-round-nearest-even.git
cd math-base-special-round-nearest-even
After cloning, you can run the following command to install dependencies:
bash
npm install
Usage
To use the rounding function, import it into your JavaScript file:
javascript
const roundNearestEven = require('math-base-special-round-nearest-even');
Now you can use the function to round numbers as needed.
API
roundNearestEven(value)
Parameters:
value(number): The number to round.
Returns:
- (number): The rounded integer.
Example
```javascript const roundNearestEven = require('math-base-special-round-nearest-even');
console.log(roundNearestEven(2.5)); // Output: 2 console.log(roundNearestEven(3.5)); // Output: 4 console.log(roundNearestEven(1.5)); // Output: 2 console.log(roundNearestEven(4.5)); // Output: 4 ```
Examples
Rounding Positive Numbers
javascript
console.log(roundNearestEven(3.2)); // Output: 3
console.log(roundNearestEven(4.7)); // Output: 5
Rounding Negative Numbers
javascript
console.log(roundNearestEven(-3.2)); // Output: -3
console.log(roundNearestEven(-4.7)); // Output: -5
Handling Edge Cases
javascript
console.log(roundNearestEven(0.5)); // Output: 0
console.log(roundNearestEven(-0.5)); // Output: 0
Contributing
Contributions are welcome! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push to your branch.
- Create a pull request.
Please ensure your code adheres to the existing style and includes appropriate tests.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- Thanks to the open-source community for their contributions and support.
- Special thanks to contributors who help improve this project.
For the latest updates and releases, visit the Releases section.
Owner
- Login: toyosang
- Kind: user
- Repositories: 1
- Profile: https://github.com/toyosang
Citation (CITATION.cff)
cff-version: 1.2.0
title: stdlib
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- name: The Stdlib Authors
url: https://github.com/stdlib-js/stdlib/graphs/contributors
repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io
abstract: |
Standard library for JavaScript and Node.js.
keywords:
- JavaScript
- Node.js
- TypeScript
- standard library
- scientific computing
- numerical computing
- statistical computing
license: Apache-2.0 AND BSL-1.0
date-released: 2016
GitHub Events
Total
- Push event: 116
Last Year
- Push event: 116
Dependencies
- @stdlib/bench-harness ^0.2.2 development
- @stdlib/console-log-each-map github:stdlib-js/console-log-each-map#main development
- @stdlib/constants-float64-ninf ^0.2.2 development
- @stdlib/constants-float64-pinf ^0.2.2 development
- @stdlib/math-base-assert-is-negative-zero ^0.2.2 development
- @stdlib/random-array-uniform ^0.2.1 development
- @stdlib/utils-try-require ^0.2.2 development
- istanbul ^0.4.1 development
- tap-min git+https://github.com/Planeshifter/tap-min.git development
- tape git+https://github.com/kgryte/tape.git#fix/globby development
- @stdlib/math-base-assert-is-even ^0.2.3
- @stdlib/math-base-assert-is-infinite ^0.2.2
- @stdlib/math-base-assert-is-nan ^0.2.2
- @stdlib/math-base-napi-unary ^0.2.3
- @stdlib/math-base-special-floor ^0.2.3
- @stdlib/utils-library-manifest ^0.2.2