Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-07 Thread Tim Rowe
2008/8/3 CNiall [EMAIL PROTECTED]: However, with some, but not all, decimals, they do not seem to 'equal themselves'. The golden rule is that working with decimals (in pretty much any language) is like working with a pile of sand. Almost anything you do leaves you with less sand and more dirt.

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-05 Thread Gabriel Genellina
En Sun, 03 Aug 2008 19:57:10 -0300, Grant Edwards [EMAIL PROTECTED] escribi�: On 2008-08-03, Larry Bates [EMAIL PROTECTED] wrote: What are they teaching in computer science classes these days? When I was an undergrad the only courses that dealt with FP issues were classes on numerical

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-05 Thread schinckel
On Aug 5, 3:26 pm, Gabriel Genellina [EMAIL PROTECTED] wrote: En Sun, 03 Aug 2008 19:57:10 -0300, Grant Edwards [EMAIL PROTECTED]   escribi : On 2008-08-03, Larry Bates [EMAIL PROTECTED] wrote: What are they teaching in computer science classes these days? When I was an undergrad the

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-05 Thread Gabriel Genellina
En Tue, 05 Aug 2008 11:50:43 -0300, schinckel [EMAIL PROTECTED] escribió: I had a class today which dealt with Decimal - IEE754 conversion, and whilst 0.1 was an example that was converted, and a representation was generated, no mention was made of the precision issue. I'm hoping that it

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-05 Thread Dave
On 3 Aug, 15:02, CNiall [EMAIL PROTECTED] wrote: However, with some, but not all, decimals, they do not seem to 'equal themselves'. Back in my days studying electrical engineering I was pointed to this reference about floating point arithmetic - http://citeseer.ist.psu.edu/goldberg91what.html

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-04 Thread Ken Starks
CNiall wrote: I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example :P), and because there is no nth-root

Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread CNiall
I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example :P), and because there is no nth-root function in

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Diez B. Roggisch
CNiall schrieb: I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example :P), and because there is no

RE: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Edwin . Madari
@python.org Subject: Decimals not equalling themselves (e.g. 0.2 = 0.21) I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Tommy Nordgren
Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of CNiall Sent: Sunday, August 03, 2008 10:03 AM To: python-list@python.org Subject: Decimals not equalling themselves (e.g. 0.2 = 0.21) I am very new to Python (I started learning it just yesterday), but I have

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Diez B. Roggisch
CNiall schrieb: I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example :P), and because there is no

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Jorgen Grahn
On Sun, 03 Aug 2008 16:50:22 +0200, Diez B. Roggisch [EMAIL PROTECTED] wrote: CNiall schrieb: ... 0.2 0.20001 ... Welcome to the wonderful world of IEEE754. Just because other languages shield you from the gory details they still are there. Python chose to not do that,

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Diez B. Roggisch
Jorgen Grahn schrieb: On Sun, 03 Aug 2008 16:50:22 +0200, Diez B. Roggisch [EMAIL PROTECTED] wrote: CNiall schrieb: ... 0.2 0.20001 ... Welcome to the wonderful world of IEEE754. Just because other languages shield you from the gory details they still are there. Python chose

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Dan Bishop
On Aug 3, 9:02 am, CNiall [EMAIL PROTECTED] wrote: I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Larry Bates
CNiall wrote: I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example :P), and because there is no nth-root

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Fuzzyman
On Aug 3, 3:02 pm, CNiall [EMAIL PROTECTED] wrote: I am very new to Python (I started learning it just yesterday), but I have encountered a problem. I want to make a simple script that calculates the n-th root of a given number (e.g. 4th root of 625--obviously five, but it's just an example

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Grant Edwards
On 2008-08-03, Larry Bates [EMAIL PROTECTED] wrote: However, it appears that when n in 1/n is a power of two, the decimal does not get 'thrown off'. How might I make Python recognise 0.2 as 0.2 and not 0.20001? This discrepancy is very minor, but it makes the whole n-th root

Re: Decimals not equalling themselves (e.g. 0.2 = 0.2000000001)

2008-08-03 Thread Steven D'Aprano
On Sun, 03 Aug 2008 17:30:29 -0500, Larry Bates wrote: As you can see, the last two decimals are very slightly inaccurate. However, it appears that when n in 1/n is a power of two, the decimal does not get 'thrown off'. How might I make Python recognise 0.2 as 0.2 and not 0.20001?