-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbit-enum.fs
More file actions
43 lines (34 loc) · 861 Bytes
/
bit-enum.fs
File metadata and controls
43 lines (34 loc) · 861 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
\ galope/bit-enum.fs
\ This file is part of Galope
\ http://programandala.net/en.program.galope.html
\ Author: Marcos Cruz (programandala.net), 2016, 2017.
\ ==============================================================
: bit-enum ( n1 "name" -- n2 )
dup constant 1 lshift dup 0= -11 and throw ;
\ doc{
\
\ bit-enum ( n1 "name" -- n2 )
\
\ Create a constant _name_ with value _n1_. Then get _n2_ by
\ shifting _n1_ 1 bit to the left. If _n2_ is zero, throw an error
\ "Result out of range", else return _n2_.
\
\ Usage example:
\
\ ----
\ 1
\ bit-enum first-bit
\ bit-enum second-bit
\ bit-enum third-bit
\ bit-enum fourth-bit
\ drop
\ ----
\
\ See: `enum`.
\
\ }doc
\ ==============================================================
\ Change log
\ 2016-07-11: Write.
\
\ 2017-10-25: Improve documentation.