Sign in Join
Wiki copytemporary

BitSizeOf: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-The compiler intrinsic function **`bitSizeOf`** returns the size of a datum in bits.
1+The compiler intrinsic function **`bitSizeOf`** returns the size of a datum in bits.
22
33## definition
44
5-`BitSizeOf` produces different results only for members of [`bitpacked`](</index.php?title=Bitpacked&action=edit&redlink=1> "Bitpacked \(page does not exist\)") structures. In all other cases the result of `bitSizeOf` is simply `8 * sizeOf(x)` (or `sizeOf(x) shl 3`). To put this relation in other words:
5+`BitSizeOf` produces different results only for members of [[Bitpacked|bitpacked]] structures. In all other cases the result of `bitSizeOf` is simply `8 * sizeOf(x)` (or `sizeOf(x) shl 3`). To put this relation in other words:
66
7-[math]\displaystyle{ \texttt{sizeOf}(\texttt{x}) = \lceil \, \texttt{bitSizeOf}(\texttt{x}) \; / \; 8 \, \rceil }[/math]
7+$`\texttt{sizeOf}(\texttt{x}) = \lceil \, \texttt{bitSizeOf}(\texttt{x}) \; / \; 8 \, \rceil`$
88
99## application
1010
11-In some cases using `bitSizeOf` can improve your code’s readability:
12-```
11+In some cases using `bitSizeOf` can improve your code’s readability:
12+
13+``` pascal
1314program binaryPrint(input, output, stdErr);
14- var
15- (* in FPC `integer` definition *)
16- (* depends on the selected mode *)
17- i: integer;
18- begin
19- readLn(i);
20- writeLn(binStr(i, bitSizeOf(i)));
21- end.
15+var
16+ (* in FPC `integer` definition *)
17+ (* depends on the selected mode *)
18+ i: integer;
19+begin
20+ readLn(i);
21+ writeLn(binStr(i, bitSizeOf(i)));
22+end.
2223```
2324
24-If your code makes presumptions about memory requirements, e. g. by using an algorithm exploiting certain properties of your `bitpacked` data type, you may want to safeguard your code with some [[Conditional compilation|conditional compilation]], may be even just for documentation purposes.
25+If your code makes presumptions about memory requirements, e. g. by using an algorithm exploiting certain properties of your `bitpacked` data type, you may want to safeguard your code with some [[Conditional compilation|conditional compilation]], may be even just for documentation purposes.
2526
2627## see also
2728
28- * [[SizeOf|`sizeOf`]]
29+- [[SizeOf|sizeOf]]
2930
3031---
31-*From the Free Pascal wiki, page "BitSizeOf", as the Internet Archive kept it on 2024-03-04. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
32+*From the Free Pascal wiki, page "BitSizeOf", as it stood on 2021-07-03 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
33+Category: Pascal

Back to history