Sign in Join
Wiki copytemporary

BitSizeOf: what changed

Revision 1 to 2. 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|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:
6-
7-<div style="text-align: center;">
8-
9-$`\texttt{sizeOf}(\texttt{x}) = \lceil \, \texttt{bitSizeOf}(\texttt{x}) \; / \; 8 \, \rceil`$
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:
106
11-</div>
7+[math]\displaystyle{ \texttt{sizeOf}(\texttt{x}) = \lceil \, \texttt{bitSizeOf}(\texttt{x}) \; / \; 8 \, \rceil }[/math]
128
139## application
1410
15-In some cases using `bitSizeOf` can improve your code’s readability:
16-
17-``` pascal
11+In some cases using `bitSizeOf` can improve your code’s readability:
12+```
1813program binaryPrint(input, output, stdErr);
19-var
20- (* in FPC `integer` definition *)
21- (* depends on the selected mode *)
22- i: integer;
23-begin
24- readLn(i);
25- writeLn(binStr(i, bitSizeOf(i)));
26-end.
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.
2722```
2823
29-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.
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.
3025
3126## see also
3227
33-- [[SizeOf|sizeOf]]
28+ * [[SizeOf|`sizeOf`]]
3429
3530---
36-*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).*
37-Category: Pascal
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).*

Back to history