Number
isZero

➕ Checks if a number is positive zero (0).

In JavaScript, standard equality 0 === -0 returns true. Use this function or Object.is() to distinguish them.

Syntax

import { isZero } from '@opentf/std';
 
isZero(n: number): boolean

Parameters

  • n: The number to check.

Returns

true if the number is 0, false otherwise (including -0).

Examples

isZero(0) //=> true
 
isZero(0.0) //=> true
 
isZero(0x0) //=> true
 
isZero(-0) //=> false
 
isZero(-0.0) //=> false

Related

Try