Last change
on this file was
495,
checked in by pinsard, 10 years ago
|
fix thanks to coding rules; typo; dupe empty lines; trailing blanks
|
-
Property svn:keywords set to
Id
|
File size:
519 bytes
|
Line | |
---|
1 | ;+ |
---|
2 | ; @file_comments |
---|
3 | ; |
---|
4 | ; @categories |
---|
5 | ; |
---|
6 | ; @param BITIN |
---|
7 | ; |
---|
8 | ; @keyword CHECKNEG |
---|
9 | ; |
---|
10 | ; @returns |
---|
11 | ; |
---|
12 | ; @uses |
---|
13 | ; |
---|
14 | ; @restrictions |
---|
15 | ; |
---|
16 | ; @examples |
---|
17 | ; |
---|
18 | ; @history |
---|
19 | ; |
---|
20 | ; @version |
---|
21 | ; $Id$ |
---|
22 | ; |
---|
23 | ; @todo |
---|
24 | ; seb |
---|
25 | ; |
---|
26 | ;- |
---|
27 | FUNCTION bit2int, bitin, CHECKNEG=checkneg |
---|
28 | ; |
---|
29 | compile_opt idl2, strictarrsubs |
---|
30 | ; |
---|
31 | |
---|
32 | res = 0L |
---|
33 | n = n_elements(bitin)-1 |
---|
34 | IF keyword_set(checkneg) THEN BEGIN |
---|
35 | IF bitin[0] EQ 1 THEN BEGIN |
---|
36 | bitin[0] = 0 |
---|
37 | neg = -1 |
---|
38 | ENDIF ELSE neg = 1 |
---|
39 | ENDIF ELSE neg = 1 |
---|
40 | FOR i = 0, n DO res = res+2L^i*bitin[n-i] |
---|
41 | |
---|
42 | RETURN, neg*res |
---|
43 | END |
---|
Note: See
TracBrowser
for help on using the repository browser.