Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do bitwise AND in SML/NJ?

Tags:

binary

sml

smlnj

Need it for a program I'm writing (repeated squaring to comput x^n). I can't seem to find the syntax for it, or if it is even supported.

like image 755
David Crosby Avatar asked Mar 02 '16 08:03

David Crosby


1 Answers

They're available within the Word8 and Word structures.

let
  open Word8
  infix andb orb xorb notb << >> ~>>
in
  print (Word8.fmt StringCvt.BIN 0wxF)             (* 1111 *)
; print "\n"
; print (Word8.fmt StringCvt.BIN 0wxA)             (* 1010 *)
; print "\n"
; print (Word8.fmt StringCvt.BIN (0wxF andb 0wxA)) (* 1010 *)
; print "\n"
end
like image 187
Ionuț G. Stan Avatar answered Dec 14 '22 10:12

Ionuț G. Stan