Patashu / break_eternity.js

A Javascript numerical library to represent numbers as large as 10^^1e308 and as small as 10^-10^^1e308. Sequel to break_infinity.js, designed for incremental games.
MIT License
120 stars 43 forks source link

Decimal.isValid() ? #165

Open QnoraeT opened 4 months ago

QnoraeT commented 4 months ago

I feel like it'll be useful if there was a way to check if strings, when attempting to convert into a Decimal, is valid maybe there is a better way to check if a string is valid when converted into a decimal, that i haven't found yet, because from what i know, it either results in NaN, or 0 (and i would like to filter out the NaN values)

maybe either this or invalid strings automatically turn into NaN ?

Decimal.isValid("1.208e38") == true
Decimal.isValid("e6.773e19") == true
Decimal.isValid("10^49") == true
Decimal.isValid("p1.208e38") == false
Decimal.isValid("Reach 15") == false
Decimal.isValid("m57") == false