Skip to content

A template tag to parse and evaluate an expression consisting of Decimal numbers and basic arithmetic operators

License

Notifications You must be signed in to change notification settings

nicolo-ribaudo/decimal-literal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@nic/decimal-literal

A template tag to parse and evaluate an expression consisting of Decimal numbers and basic arithmetic operators (+, -, *, /).

The default export uses the global Decimal constructor, while createDecimalTag allows providing your own Decimal implementation.

Installation

See the JSR docs on how to use packages from the JSR registry.

Examples

import d from "@nic/decimal-literal";
d`0.1 + 0.2`.equals(d`0.3`); // true
import d from "@nic/decimal-literal";
d`0.1`.toPrecision(20) === "1.1000000000000000000"; // true
import d from "@nic/decimal-literal";
const zeroPointTwo = d`0.2`;
d`0.1 + ${zeroPointTwo}`.equals(d`0.3`); // true

About

A template tag to parse and evaluate an expression consisting of Decimal numbers and basic arithmetic operators

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages