Skip to Content
NumbertoDecimal

toDecimal

Parses the string to decimal and returns fallback when the value is not finite

Import

import { toDecimal } from './toDecimal.ts';

Signature

function toDecimal(s: Nullable<string>, fallback: number = NaN): number {}

Examples

toDecimal('S') // NaN toDecimal(null) // NaN toDecimal(null, 10) // 10 toDecimal('100') // 100 toDecimal('1.42') // 1 toDecimal('S', 10) // 10 toDecimal('S', undefined) // NaN
Last updated on