On Tuesday 30 October 2007 17:31, Inga Petuhhov wrote:
A copy-paste from Python Shell:
a = 1
a
1
a = a + 0.4
a
1.3999
a = a - 0.4
a
0.99989
a == 1
False
Or a bit more simple (and for some maybe even more surprising):
1.0 == 0.4 - 0.4 + 1.0
True
The discussion about PI reminds me another funny quote:
The primary purpose of the DATA statement is to give names to
constants; instead of referring to pi as 3.141592653589793 at every
appearance, the variable PI can be given that value with a DATA
statement and used instead of the longer form
On Tue, Oct 30, 2007 at 07:36:39PM +0200, Musan Antal wrote:
The discussion about PI reminds me another funny quote:
The primary purpose of the DATA statement is to give names to
constants; instead of referring to pi as 3.141592653589793 at every
appearance, the variable PI can be given that
El mar, 30-10-2007 a las 19:36 +0200, Musan Antal escribió:
Oh, my GOD!
I hope, in the current eternity, no change in the value of pi might
occur!
I bet the circles will never will be the same if that happens.:P
___
fpc-pascal maillist -
El mar, 30-10-2007 a las 02:28 +0100, mm escribió:
Joao Morais a écrit :
Daniël Mantione wrote:
And, as said before, no datastructure is adequate for storing a
mathematical real number. Not even if you have infinite memory.
Nope. If infinite memory was tangible, you would be able to
Germán Pablo Gentile - PetroBox a écrit :
El mar, 30-10-2007 a las 02:28 +0100, mm escribió:
Joao Morais a écrit :
Daniël Mantione wrote:
And, as said before, no datastructure is adequate for storing a
mathematical real number. Not even if you have infinite memory.
Nope. If infinite memory
But someone tried to reproduce the example with other programming languages?
mm ha scritto:
Tom Verhoeff a écrit :
In fact, the GMP (GNU Multiple Precision Arithmetic Library
gmplib.org)
offers this and more. Unfortunately, there does not seem to be a
complete
FreePascal interface for
A copy-paste from Python Shell:
a = 1
a
1
a = a + 0.4
a
1.3999
a = a - 0.4
a
0.99989
a == 1
False
Best regards
Inga
PS I always talk to my informatics-students: You never-ever do with
real-variables something like this: if real1 = real2 then ...
Real numbers
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 1.
My opinion:
This is ludicrous.
The end user
On Mon, 29 Oct 2007, L wrote:
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 1.
My
The programmer definitely should care. He has to make the right choice
in what type he chooses, so he must be aware of any 'quircks' of the type
he is using, and that includes how things are rounded and how they are
stored in memory. That's why there are IEEE references for this.
It's his
On 29 Oct 2007, at 15:30, L wrote:
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 1.
My opinion:
Op Mon, 29 Oct 2007, schreef L:
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 1.
My
Your Casio doesn't do comparisons. Just round to 10 digits before you
compare and it'll work just as fine as on your Casio.
Daniël
And some off topic trivia:
My casio says 10 + 2 digits near the model number.
Does this mean it displays 10 digits and stores 2 in the background, or that I
On Mon, 29 Oct 2007, L wrote:
The programmer definitely should care. He has to make the right choice
in what type he chooses, so he must be aware of any 'quircks' of the type
he is using, and that includes how things are rounded and how they are
stored in memory. That's why there are
Op Mon, 29 Oct 2007, schreef L:
Your Casio doesn't do comparisons. Just round to 10 digits before you
compare and it'll work just as fine as on your Casio.
Daniël
And some off topic trivia:
My casio says 10 + 2 digits near the model number.
Does this mean it displays 10
On Mon, Oct 29, 2007 at 07:30:03AM -0700, L wrote:
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4
The end user is using a high level language and should not care whether the
computer is digital or analog.
Unfortunately, there is a problem. One can try to hide it (as calculators
attempt to do), but in the longer run that is going to be unsuccessful
and even dangerous.
Same as
Op Mon, 29 Oct 2007, schreef L:
Same as ansistring.. it can be dangerous to hide all the intricate details of
a
pchar/bytearray, which is what ansistring does. But ansistrings are really
useful for 'every day' use.
Wrong. A string can be represented alphadequate, as it is called; an
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 1.
In binary that is 0001 +
Op Mon, 29 Oct 2007, schreef Stephen Dickason:
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 -
Stephen Dickason wrote:
In binary that is 0001 + 0.0110011001100 - 0.0110011001100 because
we hit recurring decimals a lot more in binary than decimal. I wonder why we
don't have a standard format (maybe we do?) that factors in the remainder as
part of the number also?
It's
L schrieb:
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 1.
My opinion:
This is ludicrous.
Daniël Mantione schrieb:
Op Mon, 29 Oct 2007, schreef L:
Your Casio doesn't do comparisons. Just round to 10 digits before you
compare and it'll work just as fine as on your Casio.
Daniël
And some off topic trivia:
My casio says 10 + 2 digits near the model number.
Does this mean it
On Mon, Oct 29, 2007 at 06:36:11PM +0100, Micha Nelissen wrote:
It's possible to create a type that stores the numerator and
denominator, but then you would need to simplify to extract common
factors on every calculation, otherwise it would quickly run out of
range (Integer or whatever you
Op Mon, 29 Oct 2007, schreef L:
Same as ansistring.. it can be dangerous to hide all the intricate details
of
a
pchar/bytearray, which is what ansistring does. But ansistrings are really
useful for 'every day' use.
Wrong. A string can be represented alphadequate, as it is called;
Same as ansistring.. it can be dangerous to hide all the intricate details of
a
pchar/bytearray, which is what ansistring does. But ansistrings are really
useful for 'every day' use.
Wrong. A string can be represented alphadequate, as it is called; an
ansistring can handle any string you
Tom Verhoeff a écrit :
In fact, the GMP (GNU Multiple Precision Arithmetic Library gmplib.org)
offers this and more. Unfortunately, there does not seem to be a complete
FreePascal interface for it. Maybe it is easy to adapt (if necessary?)
the GNU Pascal interface for GMP
Daniël Mantione wrote:
And, as said before, no datastructure is adequate for storing a
mathematical real number. Not even if you have infinite memory.
Nope. If infinite memory was tangible, you would be able to store any
real number.
--
Joao Morais
Joao Morais a écrit :
Daniël Mantione wrote:
And, as said before, no datastructure is adequate for storing a
mathematical real number. Not even if you have infinite memory.
Nope. If infinite memory was tangible, you would be able to store any
real number.
How many time would it take to
This behaviour normal and while annoying, it is simply how things work
in the digital world, you will have to work around it.
Daniël
oh yes, this is one of the possible workarounds:
function is_equal_dbl(a ,b : double ) : boolean;
const
epsilon = 1e-14;
begin
result:=Abs(a - b ) epsilon;
31 matches
Mail list logo