Re: Possible Mac OS Bug with FIX. [message #44030 is a reply to message #44028] |
Wed, 11 May 2005 11:10   |
Foldy Lajos
Messages: 268 Registered: October 2001
|
Senior Member |
|
|
Hi,
my guess is that the two fix() calls do different things:
- fix(tmp[15]) does convert a 1-byte integer to a 2-byte integer, using
a conversion instruction in the CPU. The result is the same on all
architectures.
- fix(tmp, 15) does read memory from the address of tmp[15] as a 2-byte
integer. No conversion instruction is used, only write (as type A) and
read (as type B). It is the good old EQUIVALENCE statement from Fortran,
and is architecture-dependent. Perhaps this should be mentioned in the
IDL docs :-)
regards,
lajos
On Wed, 11 May 2005, David Fanning wrote:
> Kenneth Bowman writes:
>
>> I think perhaps you want fix(tmp, 14)?
>>
>> IDL> tmp = bytarr(20)
>> IDL> tmp[15] = 5
>> IDL> print, fix(tmp[15])
>> 5
>> IDL> print, fix(tmp, 14)
>> 5
>>
>> I think it is not a question of endianess, but of "which 2 bytes belong to the
>> 2-byte integer".
>
> What we are really looking for is consistency across
> architectures. :-)
>
> Cheers,
>
> David
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
>
|
|
|