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-0.72%
Maintainers
1
Install size
6.46 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

v0.1.0 - 2014-05-13

Commits

  • Make sure old and unstable nodes don't break Travis f627215
  • Updating deps b502f48
  • Oops, negative numbers were negative zero! 746cb97
  • Updating covert 99ef4ed
  • Updating tape ee9cfc2
  • Testing on node 0.6 again 6a9bf0a

Readme

Source

#is-negative-zero Version Badge

Build Status dependency status dev dependency status

npm badge

browser support

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 13 May 2014

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