Skip to content

Commit

Permalink
[std.bitmanip] Make 3 examples runnable
Browse files Browse the repository at this point in the history
  • Loading branch information
ntrel authored and dlang-bot committed Jun 3, 2024
1 parent ccd3115 commit ad9f87d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions std/bitmanip.d
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,7 @@ private struct FloatingPointRepresentation(T)
Allows manipulating the fraction, exponent, and sign parts of a
`float` separately. The definition is:
$(RUNNABLE_EXAMPLE
----
struct FloatRep
{
Expand All @@ -819,6 +820,7 @@ struct FloatRep
enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1;
}
----
)
*/
alias FloatRep = FloatingPointRepresentation!float;

Expand Down Expand Up @@ -874,6 +876,7 @@ alias FloatRep = FloatingPointRepresentation!float;
Allows manipulating the fraction, exponent, and sign parts of a
`double` separately. The definition is:
$(RUNNABLE_EXAMPLE
----
struct DoubleRep
{
Expand All @@ -888,6 +891,7 @@ struct DoubleRep
enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11;
}
----
)
*/
alias DoubleRep = FloatingPointRepresentation!double;

Expand Down Expand Up @@ -1050,6 +1054,8 @@ public:
of a type different than `size_t`, firstly because its length should
be a multiple of `size_t.sizeof`, and secondly because how the bits
are mapped:
$(RUNNABLE_EXAMPLE
---
size_t[] source = [1, 2, 3, 3424234, 724398, 230947, 389492];
enum sbits = size_t.sizeof * 8;
Expand All @@ -1060,6 +1066,7 @@ public:
assert(ba[n] == nth_bit);
}
---
)
The least significant bit in any `size_t` unit is the starting bit of this
unit, and the most significant bit is the last bit of this unit. Therefore,
passing e.g. an array of `int`s may result in a different `BitArray`
Expand Down

0 comments on commit ad9f87d

Please sign in to comment.