Thread: I got a 3.1399968427..........

  1. #1
    flashing vampire black's Avatar
    Join Date
    May 2002

    Question I got a 3.1399968427..........

    it is strange that I named a float variable and value it with 3.14, but it show me a the screen, what's wrong ?

    Note: my soft is BCB.
    Never end on learning~

  2. #2
    Evil Member
    Join Date
    Jan 2002
    There are a number of situations where floats arent accurate, but I don't recall ever seeing one EXTEND output, usually it gets truncated.

    The cause is that a float uses [implementation-defined] ones and zeros to represent the mantissa (decimal part) and occasionally certain decimal values cannot be represented using that number of bits. Binary numbers are good for integers, but when you get into part of numbers, errors happen. Using doubles or long doubles can stave this off, but for any number of mantissa bits, there are still decimal numbers that cannot be represented.

Popular pages Recent additions subscribe to a feed