Clone this repo, have baser.el
in the load-path
and (require
'baser)
.
Functions called using M-x
or key bindings.
- Select a region in which you want to convert all the numbers.
- Run
<conversion function>
interactively.
- Run
<conversion function>
interactively. - Type the number you want to convert.
Call eval-expression
(bound to M-:
by default) and type the elisp
expression of the conversion function.
- Examples
-
(baser-dec-to-hex 100) ;; => "00000064" (baser-dec-to-hex "8'd55") ;; => "37" (baser-dec-to-hex "-8'd55") ;; => "c9" (baser-hex-to-dec "0x100") ;; => 256 (baser-hex-to-dec "12'hfff") ;; => -1 (baser-hex-to-dec "16'hfff") ;; => 4095 (baser-hex-to-bin "0xabc") ;; => "1010_1011_1100" (baser-bin-to-hex "4'b1101") ;; => "d" (baser-dec-to-bin "4'd3") ;; => "0011" (baser-dec-to-bin "-8'd3") ;; => "1111_1101" (baser-bin-to-dec "1111") ;; => 15 (baser-bin-to-dec "4'b1111") ;; => -1 (baser-bin-to-dec "5'b1111") ;; => 15
From Base | To Base | Function |
---|---|---|
10 (number or string) | 16 (string) | baser-dec-to-hex |
16 (string) | 10 (number) | baser-hex-to-dec |
16 (string) | 2 (string) | baser-hex-to-bin |
2 (string) | 16 (string) | baser-bin-to-hex |
10 (number or string) | 2 (string) | baser-dec-to-bin |
2 (string) | 10 (number) | baser-bin-to-dec |
make test
Run make test MATCH=<string>
. For example, to run all tests where
the name matches “hex-to-dec” completely or partially, run:
make test MATCH=hex-to-dec