Variable size/Get: Difference between revisions

From Rosetta Code
(New page: {{task}} Demonstrate how to get the size of a variable. ==Ada== Category:Ada Ada represents the size of a variable in bits, not bytes like many other languages. Int_Bits : consta...)
 
(No difference)

Revision as of 03:24, 27 February 2007

Task
Variable size/Get
You are encouraged to solve this task according to the task description, using any language you may know.

Demonstrate how to get the size of a variable.

Ada

Ada represents the size of a variable in bits, not bytes like many other languages.

Int_Bits : constant Integer := Integer'size;
Whole_Bytes : constant Integer := Int_Bits / Storage_Unit; -- Storage_Unit is the number of bits per storage element