dogescript / DSON

Description and website of the Doge Serialized Object Notation, a data-interchange textformat that is easy to read and write for Shiba Inu dogs.
29 stars 14 forks source link

exp base is ambiguous #3

Closed arrdem closed 10 years ago

arrdem commented 10 years ago

The spec suggests that the exponents are base 8, as are all other numbers in dson, but the example given of 42very3 -> 24e3 suggests that exponents are base 10 rather than being base 8 in which case the example should be 42very3 -> 17408 and most of the standard-compliant implementations are wrong including mine.

In a base 8 exponent, the base should be multiplied by 8 to the power N for N being a base 8 number, whereas the given example shows that while N may be read in base 8, the exponent part is not in base 8 but is in base 10, that is the expression is M_10^N rather than M_8^N.

cerlestes commented 10 years ago

You're totally right. After staring at your post for some hours, I finally understand and changed the example to be hopefully correct. shibe bad at mathematics.

I'll include number-heavy examples in the test-cases that I've mentioned in #1 I'll close this issue for now. Thanks you very much!

petedmarsh commented 10 years ago

I'm still unsure what the correct way to interpret numbers in scientific notation in DSON is, could you clarify?

From the example this seems to be the case:

42very3 === 42 * 10 ^ 3 (all in base 10) === 42000 (base 10, treat as octal) === 17408 (base 10)

is that right?

Edit:

Ok, I've got it now:

428 * 88 ^ 38 === 3210 * 810 ^ 310 === 1740810.