Skip to content

Latest commit

 

History

History
32 lines (20 loc) · 893 Bytes

is-negative-zero.md

File metadata and controls

32 lines (20 loc) · 893 Bytes
标题 标签
isNegativeZero(是否负零) math(数学)

检查给定值是否等于负零 (-0)。

  • 检查传递的值是否等于 0,以及 1 除以该值是否等于 -Infinity。
const isNegativeZero = val => val === 0 && 1 / val === -Infinity;

ts 代码如下:

调用方式:

isNegativeZero(-0); // true
isNegativeZero(0); // false

应用场景

以下是一个实战示例:

结果如下:

<iframe src="codes/javascript/html/is-negative-zero.html"></iframe>