wschella / Sparqlee

Simple SPARQL expression evaluator library
0 stars 0 forks source link

Deal with JS number limitation #11

Open wschella opened 6 years ago

wschella commented 6 years ago

The XML Schema DataType spec for integers specifies no lower or upper size bound. Due to the limitations of JS numbers, we can't support this full space natively, and automatic conversions might turn out weird when original input is too large.

wschella commented 6 years ago

Pretty important aspect of this is how floats are handled: JS will parse a float 1.5e1 with engineering notation as 15, but as defined by the lexical representation in XML-Schema, it should be 3 (as 1.5 * 2^1). I don't seem to find an immediate solution online.

joachimvh commented 6 years ago

Floats are built using powers of 2, which is what is meant with m × 2^e, but the actual notation 1.5e1 still corresponds to 15. The 2 e's here are different, in the first case it's a variable that is filled in to calculate the float, in the second case the e is an indicator that we're using scientific notation. I agree that this is not clearly written in the explanation though.

wschella commented 6 years ago

Aha, good to know, this means +- 15 tests are actually supposed to be succeeding, and it removes the float parsing problem. Thanks!

wschella commented 6 years ago

This seems out of scope.

wschella commented 6 years ago

It might actually not be, but it's definitely low priority.

This could be useful: https://developers.google.com/web/updates/2018/05/bigint