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

Home » Public Forums » archive » Re: 32/19 = 1
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: 32/19 = 1 [message #58642] Sat, 09 February 2008 13:40
woopik is currently offline  woopik
Messages: 18
Registered: September 2007
Junior Member
strange but truth :D thx
Re: 32/19 = 1 [message #58643 is a reply to message #58642] Sat, 09 February 2008 12:14 Go to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On Feb 9, 7:21 pm, woo...@interia.pl wrote:
> Hi
>
> like in topic
> iget 1 when i make 32/19 or other float
> operation it seem my idl round (-> integer) evry results
> my question is WHY
>
> http://rapidshare.com/files/90474007/cestquoi.jpg.html
>
> thx
> Wojtek

This is because IDL assumes that both of your input numbers (32 and
19) are integers (or longword integers, depending on your settings,
but the result will be the same), and will give the result in the same
format as the input by default. If you want a float output, you'll
have to cast at least one of the inputs to float, e.g.:
print, 32.0 / 19
print, 32 / 19.0
print, FLOAT(32) / 19
print, 32e1 / 19 ; 32e1 == 32 x 10^1
print, FIX(32, TYPE = 4) / 19

note that FLOAT(32/19) will give you the wrong answer, 1.00000, as
you're converting to float AFTER the (integer / integer) division.

Cheers,
Chris
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: 32/19 = 1
Next Topic: MPFit: changing the cost function

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

Current Time: Wed Oct 08 19:22:14 PDT 2025

Total time taken to generate the page: 0.00418 seconds