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

Read instance of Double is incorrect #878

Closed
adamschoenemann opened this issue Sep 10, 2018 · 2 comments
Closed

Read instance of Double is incorrect #878

adamschoenemann opened this issue Sep 10, 2018 · 2 comments

Comments

@adamschoenemann
Copy link

Description

The Read instance for Double is completely incorrect!

Expected Behavior

That show . read = id.

Actual Behavior

It seems like the fractional part is computed wildly incorrectly. For example read "42.42" :: Double yields 66.28125. It seems the error is enlarged as the numbers grow. Here is the output of reading the doubles from 0 to 2 in increments of 0.1.

mapM_ print (Prelude.map (read . show) [0 :: Double,0.1..2] :: [Double]) 
{-- yields
0.0
0.125
0.25
0.41633363423443376
0.4440892098500627
0.5551115123125784
0.666133814775094
0.7771561172376097
1.0
1.125
1.0
1.375
1.332267629550188
1.443289932012704
1.5543122344752196
1.6653345369377353
2.8421709430404016
1.8873791418627668
1.9984014443252827
2.1094237467877983
3.5527136788005027
--}

Note that Float exhibits the same kind of erroneous behaviour, whereas the types from Data.Fixed work as expected.
I've observed this behaviour both in the eta repl and when running the code directly.

Possible Fix

I assume this must've been working before but was a regression introduced in the recent port of base-4.11.1.0.

Your Environment

  • Did you install an older version of Eta/Etlas before? No
  • Current Eta & Etlas version:
    • Eta Version 0.8.6b2, Git Revision 107507ceb487529370d987256a4996cd07450323
    • etlas version 1.5.1.0 compiled using version 2.1.0.0 of the etlas-cabal library
  • Operating System and version: Ubuntu 18.04
  • Link to your project:
@Jyothsnasrinivas
Copy link
Member

Jyothsnasrinivas commented Sep 12, 2018

@adamschoenemann Thanks for reporting this. On the latest master this is resolved.

There was a bug in the implementation of integerLog2IsPowerOf2# function in the integer package which has been resolved now.

Feel free to open new issues if you face anymore problems.

@adamschoenemann
Copy link
Author

Thanks, it works now!

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

No branches or pull requests

2 participants