Reputation: 167
How should I do a hexademical calculation in OCaml? For example I want to multiply 0x0a and 0xff.
What should I do?
Upvotes: 2
Views: 321
Reputation: 80325
For the whole package, use Printf.printf "%x\n" (0x0a * 0xff)
.
The %x
conversion prints in hexadecimal, and integer constants in the program can be typed in hexadecimal with the 0x
prefix.
Example:
$ rlwrap ocaml OCaml version 4.01.0 # Printf.printf "0x%x\n" (0x0a * 0xff);; 0x9f6
Upvotes: 2
Reputation: 35280
0x0a * 0xff
Hexadecimal is just yet another notation, not another algebra.
Upvotes: 2