|
Re: 32/19 = 1 [message #58643 is a reply to message #58642] |
Sat, 09 February 2008 12:14  |
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
|
|
|