File: test_byte_conversion.pro

package info (click to toggle)
gnudatalanguage 0.9.5-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 15,228 kB
  • ctags: 11,455
  • sloc: cpp: 143,352; makefile: 426; sh: 103; ansic: 44; awk: 18; python: 6
file content (27 lines) | stat: -rw-r--r-- 758 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;
; AC 12 Mars 2008
; testing the BYTE conversion for different types
;
pro test_byte_conversion, negative=negative, help=help
;
if KEYWORD_SET(help) then begin
  print, 'pro test_byte_conversion, negative=negative, help=help'
  return
endif

array=[255,256., 257, 258]

if KEYWORD_SET(negative) then sign=-1 else sign=1

print, 'imput data : ', array

for ii=1,4 do begin
   print, 'power ', ii
   print, '(integer 2 byte) ', byte(sign*(fix(array)^ii))
   print, '(  float 2 byte) ', byte(sign*(array^ii))
   print, '( double 2 byte) ', byte(sign*(double(array)^ii))
   print, '(complex 2 byte) ', byte(sign*(complex(array)^ii))
   print, '(   long 2 byte) ', byte(sign*(long(array)^4))
   print, '(  ulong 2 byte) ', byte(sign*(ulong(array)^4))
endfor
end