From: superpollo on
how much is one half times one half?
From: Tim Chase on
superpollo wrote:
> how much is one half times one half?


Uh, did you try it at the python prompt? If not, here's the answer:

0.1b * 0.1b = 0.01b

Now all you need is to find the recent thread that converts
binary floats to decimal floats ;-)

-tkc


From: Patrick Maupin on
On Apr 1, 4:42 pm, Tim Chase <python.l...(a)tim.thechases.com> wrote:
> superpollo wrote:
> > how much is one half times one half?
>
> Uh, did you try it at the python prompt?  If not, here's the answer:
>
>   0.1b * 0.1b = 0.01b
>
> Now all you need is to find the recent thread that converts
> binary floats to decimal floats ;-)
>
> -tkc

I thought it was 0b0.1 * 0b0.1 == 0b0.01

Otherwise, you might get it confused with hexadecimal floats :D
From: David Robinow on
On Thu, Apr 1, 2010 at 7:34 PM, Patrick Maupin <pmaupin(a)gmail.com> wrote:
> On Apr 1, 4:42 pm, Tim Chase <python.l...(a)tim.thechases.com> wrote:
>> superpollo wrote:
>> > how much is one half times one half?
>>
>> Uh, did you try it at the python prompt?  If not, here's the answer:
>>
>>   0.1b * 0.1b = 0.01b
>>
>> Now all you need is to find the recent thread that converts
>> binary floats to decimal floats ;-)
>>
>> -tkc
>
> I thought it was 0b0.1 * 0b0.1 == 0b0.01
>
> Otherwise, you might get it confused with hexadecimal floats :D
Well, my python says:

$ python -c "print 1/2 * 1/2"
0

But that's not what I learned in grade school.
(Maybe I should upgrade to 3.1?)
From: Tim Chase on
David Robinow wrote:
> $ python -c "print 1/2 * 1/2"
> 0
>
> But that's not what I learned in grade school.
> (Maybe I should upgrade to 3.1?)

That's because you need to promote one of them to a float so you
get a floating-point result:

>>> 1/2 * 1/2
0
>>> 1/2 * 1/2.0
0.0

Oh...wait ;-)

-tkc