Viewing contents of file '../idllib/iuedac/iuelib/pro/bittest.pro'
;************************************************************************
;+
;*NAME:
;
; BITTEST (General IDL Library 01) 30-MAR-83
;
;*CLASS:
;
; Utilities
;
;*CATEGORY:
;
;*PURPOSE:
;
; TO TEST BIT N IN FIX(X)
;
;*CALLING SEQUENCE:
;
; BITTEST,X,N,YESNO
;
;*PARAMETERS:
;
; X (REQ) (I) (0 1) (I F)
; X is the variable to be tested
;
; N (REQ) (I) (0) (I)
; The bit of X to be tested
;
; YESNO (REQ) (O) (0 1) (I)
; The result of the test. 1(true) if bit N is set, 0(false)
; otherwise.
;
;*EXAMPLES:
;
; BITTEST,!X.STYLE,4,YESNO
; IF YESNO THEN PRINT,'X-axis suppressed' $
; ELSE PRINT,'Draw X-axis'
;
; To find points in NEWSIPS which are outside calibrated region:
; BITTEST,ABS(NU),1,YESNO ; look for nu flag = -2
; IND = WHERE (YESNO EQ 0) ; keep points where yesno = 0
; PLOT,W(IND),F(IND) ; plot calibrated points
;
;*SYSTEM VARIABLES USED:
;
;*INTERACTIVE INPUT:
;
;*SUBROUTINES CALLED:
;
; PARCHECK
;
;*FILES USED:
;
;*SIDE EFFECTS:
;
;*RESTRICTIONS:
;
;*NOTES:
;
; Note that negative integers are stored in twos complement form.
; Therefore, the left-most bits are ON rather than OFF as they are for
; positive numbers. Input the absolute value of X is negative numbers
; to avoid this problem.
;
; This procedure can be used to check the values of complex
; IDL system variables such as ![XYZ].STYLE.
;
; tested with IDL Version 2.1.0 (sunos sparc) 19 Jun 91
; tested with IDL Version 2.1.0 (ultrix mispel) N/A
; tested with IDL Version 2.1.0 (vms vax) 09 Mar 93
;
;*PROCEDURE:
;
; Checks whether (FIX(X) OR (NOT 2^N)) = -1 to set the output
; flag YESNO.
;
;*MODIFICATION HISTORY:
;
; Mar 6 1983 RJP GSFC initial program
; Aug 24 1987 RWT GSFC add PARCHECK
; Mar 7 1988 CAG GSFC all VAX RDAF-style prolog
; Jul 13 1990 RWT GSFC Sun mods: use examples pertinent to SUN IDL
; and add listing of procedure call statement
; Jun 19 1991 PJL GSFC cleaned up; tested on SUN and VAX; updated prolog
; Mar 8 1993 RWT GSFC modify to allow X & YESNO to be vectors and
; add documentation about negative numbers.
;-
;*********************************************************************
pro bittest,x,n,yesno
if n_params() eq 0 then begin
print,' BITTEST,X,N,YESNO'
retall
endif ; n_params()
parcheck,n_params(0),3,'BITTEST'
yesno = ( fix(x) or (not 2^n) ) eq -1
; if ( (fix(x) or (not 2^n)) eq -1) then yesno = 1 else yesno=0
return
end ; bittest