Re: float / rounding question

2008-03-10 Thread Piet van Oostrum
> Dennis Lee Bieber <[EMAIL PROTECTED]> (DLB) wrote: >DLB> On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum <[EMAIL PROTECTED]> >DLB> declaimed the following in comp.lang.python: >>> Sorry to come in so late in this discussion. Although it is correct to say >>> that many real numbers tha

Re: float / rounding question

2008-03-08 Thread Roel Schroeven
Mark Dickinson schreef: > On Mar 7, 11:23 pm, Steven D'Aprano <[EMAIL PROTECTED] > cybersource.com.au> wrote: >> On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote: >>> Sorry to come in so late in this discussion. Although it is correct to >>> say that many real numbers that have an exact d

Re: float / rounding question

2008-03-08 Thread Mark Dickinson
On Mar 8, 11:34 am, Mark Dickinson <[EMAIL PROTECTED]> wrote: > following, which arises from Python arbitrarily stripping trailing > zeros from the result returned by the C library functions: Correction: on closer examination it's not Python doing the stripping of trailing zeros; it's the C librar

Re: float / rounding question

2008-03-08 Thread Mark Dickinson
On Mar 7, 11:23 pm, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote: > > Sorry to come in so late in this discussion. Although it is correct to > > say that many real numbers that have an exact decimal representation > > can

Re: float / rounding question

2008-03-07 Thread Steven D'Aprano
On Fri, 07 Mar 2008 23:12:27 +0100, Piet van Oostrum wrote: > Sorry to come in so late in this discussion. Although it is correct to > say that many real numbers that have an exact decimal representation > cannot be exactly represented in binary, that is no excuse to print 53.6 > as 53.600

Re: float / rounding question

2008-03-07 Thread Mark Dickinson
On Mar 7, 5:12 pm, Piet van Oostrum <[EMAIL PROTECTED]> wrote: > Python just uses the C library for printing, I presume, and the conversion > routines in the C library are rather simplistic. It is, however, possible > to do better, so that 53.6 -- although internally represented as something > that

Re: float / rounding question

2008-03-07 Thread Piet van Oostrum
> casevh <[EMAIL PROTECTED]> (C) wrote: >C> On Feb 25, 2:44 am, [EMAIL PROTECTED] wrote: >>> Hi I'm very much a beginner with Python. >>> I want to write a function to convert celcius to fahrenheit like this >>> one: >>> >>> def celciusToFahrenheit(tc): >>> tf = (9/5)*tc+32 >>> return tf >>>

Re: float / rounding question

2008-02-25 Thread John Machin
On Feb 26, 7:14 am, "Terry Reedy" <[EMAIL PROTECTED]> wrote: > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > | Hi I'm very much a beginner with Python. > | I want to write a function to convert celcius to fahrenheit like this > | one: > | > | def celciusToFahrenheit(tc): > |

Re: float / rounding question

2008-02-25 Thread Terry Reedy
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hi I'm very much a beginner with Python. | I want to write a function to convert celcius to fahrenheit like this | one: | | def celciusToFahrenheit(tc): |tf = (9/5)*tc+32 |return tf Unless you are importing 'integer division'

Re: float / rounding question

2008-02-25 Thread Mel
[EMAIL PROTECTED] wrote: > Hi I'm very much a beginner with Python. > I want to write a function to convert celcius to fahrenheit like this > one: > > def celciusToFahrenheit(tc): > tf = (9/5)*tc+32 > return tf > > I want the answer correct to one decimal place, so > celciusToFahrenheit(1

Re: float / rounding question

2008-02-25 Thread Sion Arrowsmith
Necmettin Begiter <[EMAIL PROTECTED]> wrote: >25 February 2008 Monday 12:44:46 tarihinde [EMAIL PROTECTED] =C5=9Fun= >lar=C4=B1 yazm=C4=B1=C5=9Ft=C4=B1: >> Of course the function above returns 53.601. >>=20 >> How do I format it correctly? > >Use the round(number,digits) function: > >t

Re: float / rounding question

2008-02-25 Thread casevh
On Feb 25, 2:44 am, [EMAIL PROTECTED] wrote: > Hi I'm very much a beginner with Python. > I want to write a function to convert celcius to fahrenheit like this > one: > > def celciusToFahrenheit(tc): > tf = (9/5)*tc+32 > return tf > > I want the answer correct to one decimal place, so > cel

Re: float / rounding question

2008-02-25 Thread Necmettin Begiter
25 February 2008 Monday 12:44:46 tarihinde [EMAIL PROTECTED] şunları yazmıştı: > Hi I'm very much a beginner with Python. > I want to write a function to convert celcius to fahrenheit like this > one: > > def celciusToFahrenheit(tc): > tf = (9/5)*tc+32 > return tf > > I want the answer co

Re: float / rounding question

2008-02-25 Thread Jorge Godoy
sabatier wrote: > On Feb 25, 10:44 am, [EMAIL PROTECTED] wrote: >> Hi I'm very much a beginner with Python. >> I want to write a function to convert celcius to fahrenheit like this >> one: >> >> def celciusToFahrenheit(tc): >> tf = (9/5)*tc+32 >> return tf >> >> I want the answer correct t

Re: float / rounding question

2008-02-25 Thread sabatier
On Feb 25, 10:44 am, [EMAIL PROTECTED] wrote: > Hi I'm very much a beginner with Python. > I want to write a function to convert celcius to fahrenheit like this > one: > > def celciusToFahrenheit(tc): > tf = (9/5)*tc+32 > return tf > > I want the answer correct to one decimal place, so > ce