Version française
Home     About     Download     Resources     Contact us    
Browse thread
How can I treat bits?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Bomshik Kim <bskim@r...>
Subject: How can I treat bits?


In C language, we can define a variable size as a unit of bits.
For example,  "unsigned int a:1 ;", " unsigned int b:4 ;" ....
"colon" is used to set up the number of bits.

Can I define OCaml-variables in the same way?
Because I want to make some data header by using bits as little as
possible. 

the style that I imagine is... 

	type hd = { flag : int_1 ; on_off : int_1 ; seq_num : int_4 } ;;
	let header = { flag = 1 ; on_off = 0 ; seq_num = 0101 } ;;

Thank you.

-BS Kim