In article <[EMAIL PROTECTED]>,
Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>> However, I can't seem to get the program to treat the numbers as
>> numbers. If I put them in the dictionary as 'THE' = int(0.965) the
>> program returns 1.0
>
>It certainoly does _not_ return 1.0 - it returns 1. And tha
[EMAIL PROTECTED] wrote:
> 'It certainoly does _not_ return 1.0 - it returns 1. And that is all it
> can
> return for being an integer that has by definition no fractional part.
> '
>
> For goodness sake, it was a typo, I'm so sorry!
>
Guess that's what you get for calling yourself "brainy_muppet
If your still worried by using floats for your values you may wish to
look into the decimal module:
http://docs.python.org/lib/module-decimal.html
Example:
>>> from decimal import Decimal
>>> Decimal(2) + Decimal('1.47')
Decimal("3.47")
Regards,
Neil
--
http://mail.python.org/mailman/listinf
[EMAIL PROTECTED] enlightened us with:
> if I put 'THE' = float(0.965) it returns 0.9655549 or something
> similar.
That's for the same reasons as you can't write 1/3rd in decimal
notation. Computers can't write 1/10th in binary notation.
Sybren
--
The problem with the world is stupidity. No
'It certainoly does _not_ return 1.0 - it returns 1. And that is all it
can
return for being an integer that has by definition no fractional part.
'
For goodness sake, it was a typo, I'm so sorry!
--
http://mail.python.org/mailman/listinfo/python-list
> It certainoly does _not_ return 1.0 - it returns 1. And that is all it can
> return for being an integer that has by definition no fractional part.
Duncan was right of course. It returns 0.
Diez
--
http://mail.python.org/mailman/listinfo/python-list
'It certainoly does _not_ return 1.0 - it returns 1. And that is all it
can
return for being an integer that has by definition no fractional part.
'
For goodness sake, it was a typo, I'm so sorry!
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> Basically, I have a code with is almost finished but I've having
> difficultly with the last stage of the process. I have a program that
> gets assigns different words with a different value via looking them up
> in a dictionary:
>
> eg if THE is in the writing, it assig
wrote:
> If I put them in the dictionary as 'THE' = int(0.965) the
> program returns 1.0 and if I put 'THE' = float(0.965) it returns
> 0.9655549 or something similar. Neither of these are right!
Your system seems to be really screwed. int(0.965) should be 0, and
float(0.965) should be 0.96
> However, I can't seem to get the program to treat the numbers as
> numbers. If I put them in the dictionary as 'THE' = int(0.965) the
> program returns 1.0
It certainoly does _not_ return 1.0 - it returns 1. And that is all it can
return for being an integer that has by definition no fractional
10 matches
Mail list logo