On 18 Apr, 17:32, F=D6LDY Lajos <fo...@[EMAIL PROTECTED]
> wrote:
> On Fri, 18 Apr 2008, vino wrote:
> > Hi!
> > I was trying out the 'FIX' command and i couldnt understand all the
> > arguments present. Can someone help me please? below is whats i did!
> > IDL> c=3D[1.2,-3.4,5.]
> > IDL> print,fix(c)
> > 1 -3 5
>
> You have converted a float array to int.
>
> FIX converts to IDL int, which is 16 bits wide, is signed and its range
is=
> -32768 <=3D int <=3D 32767. I assume you know how numbers are
represented =
in
> computers. (The following is valid on little-endian machines only.)
>
> Your float array occupies 12 bytes in memory, namely:
>
> 154 153 153 63 154 153 89 192 0 0 160 64 (in decimal)
>
> > IDL> print,fix(c,0)
> > -26214
>
> reads memory as int from offset 0: the two bytes 154, 153 give -26214
> (154+256*153 =3D 39322 =3D 65536-26214 =3D -26214)
>
> > IDL> print,fix(c,1)
> > -26215
>
> reads memory as int from offset 1: the two bytes 153, 153 give -26215
> (153+256*153 =3D 39321 =3D 65536-26215 =3D -26215)
>
> > IDL> print,fix(c,2)
> > 16281
>
> reads memory as int from offset 2: the two bytes 153, 63 give 16281
> (153+256*63 =3D 16281)
>
> > IDL> print,fix(c,0,1)
> > -26214
>
> same as first, reads 1 int (from offset 0)
>
> > IDL> print,fix(c,0,2)
> > -26214 16281
>
> same as first and third, reads 2 ints (from offset 0 and 2)
>
> regards,
> lajos
Hi Lajos,
Thank you very much for explaining me. I didnt know how floating point
numbers are represented in binary.
I understand it very well now. thank you very much,#
regards,
vino


|