Ticket #68 (closed defect: invalid)

Opened 6 years ago

Last modified 6 years ago

Subtraction Error

Reported by: neumarcx Owned by: nobody
Priority: major Milestone:
Component: hugs Version: 200609
Keywords: arithmetic operations Cc:

Description

Why is the difference between minuend and subtrahend wrong, if you use any 5 digit exponent for floating point numbers ?

e.g.

Version: Sep 2006 Haskell 98 mode: Restart with command line option -98 to enable extensions

Type :? for help Hugs> 12345 - 12345.1 -0.100000000000364

Change History

Changed 6 years ago by ross

  • status changed from new to closed
  • resolution set to invalid

This is normal behaviour for floating point types in any language: being fixed size binary formats, they can represent decimal fractions only approximately. For operations on exact fractions, Haskell provides Rational.

Note: See TracTickets for help on using tickets.