Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Float" in J8 should probably be "Decimal" #1968

Open
l0b0 opened this issue May 13, 2024 · 3 comments
Open

"Float" in J8 should probably be "Decimal" #1968

l0b0 opened this issue May 13, 2024 · 3 comments

Comments

@l0b0
Copy link

l0b0 commented May 13, 2024

IIUC, the JSON number type uses the integer fraction exponent format, which represents arbitrary-precision decimals. These in general don't map cleanly to any floating point representation, so the specification should probably be clear that these are decimal rather than floating point numbers.

@andychu
Copy link
Contributor

andychu commented May 18, 2024

JSON is a grammar, i.e. syntax-only -- it doesn't specify what types a given JSON message maps to

It fundamentally can't because Python, JavaScript, C++, etc. have different types

Oils behaves like Python -- 42 is mapped to an integer, while 42.1 is mapped to a float

(and I think Ruby probably has this behavior, maybe Raku, PHP, etc.)

@andychu
Copy link
Contributor

andychu commented May 18, 2024

i.e. J8 is like JSON and is logically separate from the interior types of Oils

It is valid to map J8 number syntax to a Decimal in some other programming language which supports Decimal

But Oils doesn't have Decimal

Maybe this can be clarified somewhere, not sure where. maybe a FAQ

andychu pushed a commit that referenced this issue May 18, 2024
Question on issue #1968

Unrelated: fix spec test.
@andychu
Copy link
Contributor

andychu commented May 18, 2024

OK I added a FAQ in doc/j8-notation, thanks for the feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants