`Data.Text.Read.rational` no more accurate than `Data.Text.Read.double` #34

Open
reinerp opened this Issue Jul 22, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@reinerp

reinerp commented Jul 22, 2012

The documentation on double states that it loses accuracy on some inputs, but using rational will fix this. I understood this to mean that if one simply used rational :: Reader Double, then one would get completely accurate results, but this doesn't appear to be the case. For instance, given the input string "5.781884674518029e-2", double :: Reader Double and rational :: Reader Double both produce an output of "5.7818846745180286e-2", whereas Prelude.read :: String -> Double produces "5.781884674518029e-2".

Perhaps the documentation means that one should actually use rational :: Reader Rational and then convert to Double with fromRational? If so, that isn't clear from the documentation.

@bitonic

This comment has been minimized.

Show comment Hide comment
@bitonic

bitonic Sep 3, 2015

I've also stumbled upon this problem.

I was wondering if there was some performance concern regarding how the read instance for Double does the parsing (as per the https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Read-Lex.html module). Otherwise, I can replicate the functionality present there but tuned to parsing Text.

bitonic commented Sep 3, 2015

I've also stumbled upon this problem.

I was wondering if there was some performance concern regarding how the read instance for Double does the parsing (as per the https://hackage.haskell.org/package/base-4.8.1.0/docs/Text-Read-Lex.html module). Otherwise, I can replicate the functionality present there but tuned to parsing Text.

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