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

Allow to parse double-float in JSON. #42

Merged
merged 1 commit into from
Oct 22, 2016

Conversation

fukamachi
Copy link
Contributor

float in Common Lisp usually means single-float and it can represent a number which has 8 digits at most.
However, JSON's float can be a double-float:

(jojo:parse "35.65910807942215")
;=> 35.659107

This patch allows jojo:parse to parse double-floats too:

(jojo:parse "35.65910807942215")
;=> 35.65910807942215d0

(jojo:parse "35.659108")
;=> 35.659108

@coveralls
Copy link

Coverage Status

Coverage remained the same at 71.667% when pulling fcfceee on fukamachi:parse-double-float into fba9d5e on Rudolph-Miller:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 71.667% when pulling fcfceee on fukamachi:parse-double-float into fba9d5e on Rudolph-Miller:master.

@rudolph-miller
Copy link
Owner

Thanks! :octocat:

@rudolph-miller rudolph-miller merged commit 459e20e into rudolph-miller:master Oct 22, 2016
@fukamachi
Copy link
Contributor Author

The test failed with ABCL.
https://travis-ci.org/Rudolph-Miller/jonathan/jobs/169708369#L947-L948

It seems the numbers after the decimal point is bigger than the range of ABCL's fixnum.

(jojo:parse "35.65910807942215")
;=> 35.00000239817799d0

most-positive-fixnum
;=> 2147483647

(typep 65910807942215 'fixnum)
;=> NIL

Perhaps the type specification at (the fixnum (parse-integer rest-num-str)) should be omitted.
https://github.com/Rudolph-Miller/jonathan/blob/master/src/decode.lisp#L272

@rudolph-miller
Copy link
Owner

Fixed. a163a0f

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

Successfully merging this pull request may close these issues.

None yet

3 participants