Skip to content

Improved results in GHCi during basic calculations

We can use GHCi as a calculator using +, -, *, /, sin, cos, and others. sometimes the result does not meet our expectations. for example if I calculate 3 + 2, the result is 5 and in line with our expectations. \\

Prelude> 3+2
5

but sometimes it is not.\\ for the two examples below, please, can we have in GHCi a result other than the one given?\\

Prelude> exp(log(1000)-log(10))
99.99999999999996

can we have a result equal to 100? \\

Prelude> 12*(1/3-1/4)-1
-2.220446049250313e-16

can we have a result equal to 0? \\

Trac metadata
Trac field Value
Version 8.2.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information