Socket
Socket
Sign inDemoInstall

is-negative-zero

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    is-negative-zero

Is this value negative zero? === will lie to you


Version published
Weekly downloads
31M
decreased by-1.3%
Maintainers
1
Install size
26.5 kB
Created
Weekly downloads
 

Package description

What is is-negative-zero?

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.

What are is-negative-zero's main functionalities?

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

Other packages similar to is-negative-zero

Changelog

Source

v2.0.3 - 2024-02-19

Commits

  • add types e28f0d5
  • [meta] use npmignore to autogenerate an npmignore file f68ec13
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, tape 70abff7
  • [actions] update rebase action to use reusable workflow 6e1356e
  • [Dev Deps] update @ljharb/eslint-config, aud, npmignore, tape c00d4ab
  • [meta] add sideEffects flag 9c45539

Readme

Source

is-negative-zero Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this value negative zero? === will lie to you.

Example

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));

Tests

Simply clone the repo, npm install, and run npm test

Keywords

FAQs

Last updated on 19 Feb 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc