comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Friday Afternoon Puzzler
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Friday Afternoon Puzzler [message #66839 is a reply to message #66834] Fri, 12 June 2009 14:09 Go to previous messageGo to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Paolo wrote:
> David Fanning wrote:
>> Folks,
>>
>> If you've already had a beer, you may want to work
>> on this one. Should we be concerned? Or is this just
>> one more example for the Sky is Falling article?
>> I've voiced my opinion, but it didn't satisfy the
>> complainant. What say you?
>>
>> curly=[-1.912,-1.852,-1.386,-0.818,-0.343,-0.343,-1.233]
>> larry=[-1.912,-1.852,-1.386,-0.818,-0.343,-0.343,-1.233]
>> curly = curly*!PI/180.
>> larry *= !PI/180.
>
> I'd argue that you are multiplying curly bi pi and dividing the result
> by 180
> in the first line, and dividing pi by 180 first and multiplying larry
> by the result
> in the second line. Therefore, you are performing two different set of
> floating
> point operations, therefore I am not surprised they give slightly
> different results.

In other words, (a*b)/c is different than a*(b/c) with floats

Paolo

>
> Ciao,
> Paolo
>
>> diff=curly-larry
>> print,diff
>>
>> curly=[-1.912,-1.852,-1.386,-0.818,-0.343,-0.343,-1.233]
>> larry=[-1.912,-1.852,-1.386,-0.818,-0.343,-0.343,-1.233]
>> curly = curly*!PI/180.
>> larry = larry*!PI/180.
>> diff=curly-larry
>> print,diff
>>
>> curly=[-1.912,-1.852,-1.386,-0.818,-0.343,-0.343,-1.233]
>> larry=[-1.912,-1.852,-1.386,-0.818,-0.343,-0.343,-1.233]
>> curly *= !PI/180.
>> larry *= !PI/180.
>> diff=curly-larry
>> print,diff
>>
>> The results:
>>
>> -3.72529e-009 0.000000 0.000000-9.31323e-010 0.000000
>> 0.000000 0.000000
>> 0.000000 0.000000 0.000000 0.000000 0.000000
>> 0.000000 0.000000
>> 0.000000 0.000000 0.000000 0.000000 0.000000
>> 0.000000 0.000000
>>
>>
>> Why aren't the first set of differences (where the assignment
>> is made with the *= operator) *exactly* zero?
>>
>> Cheers,
>>
>> David
>>
>>
>> --
>> David Fanning, Ph.D.
>> Fanning Software Consulting, Inc.
>> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Checking version number
Next Topic: 4 byte integers

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 08:33:29 PDT 2025

Total time taken to generate the page: 0.23941 seconds