Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
is-negative-zero
Advanced tools
Package description
The is-negative-zero npm package is a utility that provides a simple function to check if a given number is -0. In JavaScript, -0 and +0 are considered distinct values (due to IEEE 754 floating point), and this package helps in identifying if a number is specifically -0.
Check if a number is -0
This feature allows you to check if a given number is exactly -0. It returns true if the number is -0, and false otherwise. This can be particularly useful in mathematical computations and graphics programming where the distinction between -0 and +0 can have implications.
const isNegativeZero = require('is-negative-zero');
console.log(isNegativeZero(-0)); // true
console.log(isNegativeZero(0)); // false
console.log(isNegativeZero(-1)); // false
Similar to is-negative-zero, is-zero is a utility for checking if a number is 0. However, it does not distinguish between -0 and +0, making it less specific for cases where the sign of zero matters.
While not specifically designed for checking -0, lodash's isEqual function can accurately compare -0 and +0, among many other complex equality checks. It's more versatile but also much larger and more complex than is-negative-zero, which is focused solely on the -0 check.
Changelog
v2.0.3 - 2024-02-19
e28f0d5
npmignore
to autogenerate an npmignore file f68ec13
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, tape
70abff7
6e1356e
@ljharb/eslint-config
, aud
, npmignore
, tape
c00d4ab
sideEffects
flag 9c45539
Readme
Is this value negative zero? === will lie to you.
var isNegativeZero = require('is-negative-zero');
var assert = require('assert');
assert.notOk(isNegativeZero(undefined));
assert.notOk(isNegativeZero(null));
assert.notOk(isNegativeZero(false));
assert.notOk(isNegativeZero(true));
assert.notOk(isNegativeZero(0));
assert.notOk(isNegativeZero(42));
assert.notOk(isNegativeZero(Infinity));
assert.notOk(isNegativeZero(-Infinity));
assert.notOk(isNegativeZero(NaN));
assert.notOk(isNegativeZero('foo'));
assert.notOk(isNegativeZero(function () {}));
assert.notOk(isNegativeZero([]));
assert.notOk(isNegativeZero({}));
assert.ok(isNegativeZero(-0));
Simply clone the repo, npm install
, and run npm test
FAQs
Is this value negative zero? === will lie to you
The npm package is-negative-zero receives a total of 23,692,359 weekly downloads. As such, is-negative-zero popularity was classified as popular.
We found that is-negative-zero demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.