Re: Rounding of the double

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance




"Alex" <alsim123@xxxxxxxxxxx> wrote in message
news:1180709515.897443.226890@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Again, everybody, please try to understand what I need, I thought
that I'd expressed myself clear enough. But I will try to do it
again:

1. I don't need the representation of this double.

No, but the computer *does*. This is the whole point.
ALL float and double variables and their associated math operations use the
internal representation in memory, as specified by IEEE

2.0 - 80.0/100.0 involves floating point math operations which may be
inexact.


2. I need to divide 8 by 10 and later on to be able use the result
0.2, not 0.199999999999999999

But obviously C++ won't allow me to do so, because of the nature of
float data type.

It is NOT the fault of C++ or any other compiler.
ALL COMPUTERS DOING FLOATING POINT ARITHMETIC WILL USE APPROXIMATIONS FOR
THOSE VALUES THAT CANNOT BE REPRESENTED EXACTLY IN MEMORY.

0.8 is one of those values.
There are others.

As you have found out, in order to give the result that you require, you
yourself have to handle the numbers in a particular way - using integers in
your case.

Or may be I want too much :)

Only if you expect the computer to produce *exact* math every time.
Les


Thanks,
Alex



.



Relevant Pages

  • Re: A step by step discussion
    ... The researchers have presented stimuli ... Read In Search Of Memory to find out. ... representation of events is an assumption. ... understand the terminology of neuroscience, ...
    (comp.ai.philosophy)
  • Re: In what language do you think?
    ... When the molecules arise again, ... thanks to the memory of our previous experiences. ... And we need a representation in our mind in order to be able to do ... but its presentation by a medium. ...
    (sci.lang)
  • Re: In what language do you think?
    ... Because the primary stimuli are ... When the molecules arise again, ... thanks to the memory of our previous experiences. ... And we need a representation in our mind in order to be able to do ...
    (sci.lang)
  • Re: Representationalism rescues reinforcement learning
    ... The hippocampus appears to have something to do with the so-called transfer of memories from short to long term memory, but the view that memory is some sort of literal storage of representations is mere assumption. ... What then is memory if not storage of a representation? ... What is it that I see when I see in my mind's eye, the "representation" of the apple on the table that was there yesterday and is no longer there? ... The same is true of eye-witness testimony, although courts have only recently come to treat eye-witness testimony as requiring corroboration. ...
    (comp.ai.philosophy)
  • Re: What is a type?
    ... >> One problem with this explanation is that it relies ... > in memory somewhere. ... > as a way of describing the bits in the machine representation ... that the two `sizeof' operands have different sizes. ...
    (comp.lang.c)