diff --git a/index.html b/index.html index 59cf923..cfee767 100644 --- a/index.html +++ b/index.html @@ -83,7 +83,6 @@ li span{float:right;margin-right:10px;color:#c0c0c0}
.fromJSON(s) ⇒ Decimal
s
: string
- Returns a new Decimal whose value is the same as the value of the Decimal that created string
- s
from a toJSON
call.
-
See toJSON
.
-a = new Decimal(x) -s = a.toJSON() -b = Decimal.fromJSON(s) -a.equals(b) // true- - -
.hypot([x [, y, ...]]) ⇒ Decimal
.toJSON() ⇒ string
- Returns a string representing the exact value of this Decimal in a compact base-88 based - format. -
-
- A Decimal instance with the same value as this Decimal can be created by passing the return
- value to the fromJSON
method of a Decimal constructor.
-
- The number of characters of the return value will always be equal to or less than the number
- of characters returned by toString
- usually just over
- half as many.
-
- The 7 printable ASCII characters, (space) \ " & ' < >
, are not used in
- the return value, so it should be safe for inclusion in HTML, JSON and XML.
-
-x = new Decimal('177.7e+457') -x.toJSON() // '25jkh' -y = new Decimal(235.4325) -y.toJSON() // '/3E1Z' -z = new Decimal('0.0098074') -z.toJSON() // '*cWG' - -// Serialize an array of three Decimals -str = JSON.stringify( [x, y, z] ) // "["25jkh","/3E1Z","*cWG"]" - -// Return an array of three Decimals -JSON.parse(str, function (key, val) { - return key === '' ? val : Decimal.fromJSON(val) -})-
If the toJSON
method was not present, deserialization would be difficult as the
- array would be serialized as:
-/* -"[{"s":1,"e":459,"c":[17770]}, - {"s":1,"e":2,"c":[235,4325000]}, - {"s":1,"e":-3,"c":[98074]}]" -*/+
As valueOf
.