Previous SAXO Documentation Assistant: Overview Next

ToBeReviewed/LECTURE/

binary.pro

Returns the binary representation of a number of any numerical type.

binary

result = binary(number)

Return value

Byte array with binary representation of numbers.

Parameters

number        in required

scalar or array of numbers (any numerical type)

Examples

Binary representation of 11b: IDL> print, binary(11b) 0 0 0 0 1 0 1 1 Binary representation of pi (x86: Little-endian IEEE representation): IDL> print, format='(z9.8,5x,4(1x,8i1))', long(!pi,0), binary(!pi) 40490fdb 01000000 01001001 00001111 11011011 (x86 Linux) 0fdb4149 00001111 11011011 01000001 01001001 (Alpha OpenVMS) IDL> print, format='(8(1x,8i0))', binary(!dpi) 01000000 00001001 00100001 11111011 01010100 01000100 00101101 00011000 Some first tests before type double was added: print, format='(2a6,4x,2z9.8,4x,8z3.2)', $ !version.arch, !version.os, long(!dpi,0,2), byte(!dpi,0,8) x86 linux 54442d18 400921fb 18 2d 44 54 fb 21 09 40 sparc sunos 400921fb 54442d18 40 09 21 fb 54 44 2d 18 alpha vms 0fda4149 68c0a221 49 41 da 0f 21 a2 c0 68 (Beginning with IDL 5.1, Alpha VMS uses IEEE representation as well.)

Version history

Version

$Id: binary.pro 142 2006-07-21 12:47:49Z navarro $

History

: 19 Dec 1997 Originally a news posting by David Fanning. (Re: bits from bytes) 20 Dec 1997 "Complete" rewrite: eliminate loops. 22 Dec 1997 Bit shift instead of exponentiation, return byte array, handle input arrays. Think about double and complex types. 22 Sep 1998 Complete rewrite: reduce every numerical type to single bytes. Check that big and little endian machines return exactly the same results (if IEEE). 7 May 2003 Added newish data types, unsigned and long64. BT

 


  Produced by IDLdoc 2.0.