View source code
							
							
						
								Display the source code in std/bitmanip.d from which this
								page was generated on github.
							
						
							Report a bug
							
						
								If you spot a problem with this page, click here to create a
								Bugzilla issue.
							
						
							
								Improve this page
							
							
					
								Quickly fork, edit online, and submit a pull request for this page.
								Requires a signed-in GitHub account. This works well for small changes.
								If you'd like to make larger changes you may want to consider using
								local clone.
							
						Module std.bitmanip
Bit-level manipulation facilities.
| Category | Functions | 
|---|---|
| Bit constructs | BitArraybitfieldsbitsSet | 
| Endianness conversion | bigEndianToNativelittleEndianToNativenativeToBigEndiannativeToLittleEndianswapEndian | 
| Integral ranges | appendpeekreadwrite | 
| Floating-Point manipulation | DoubleRepFloatRep | 
| Tagging | taggedClassReftaggedPointer | 
Functions
| Name | Description | 
|---|---|
| 
									append(range, value)
								 | Takes an integral value, converts it to the given endianness, and appends
    it to the given range of ubytes (usingput) as a sequence ofTubytes starting at index.hasSlicing!Rmust betrue. | 
| 
									bigEndianToNative(val)
								 | Converts the given value from big endian to the native endianness and
    returns it. The value is given as a ubyte[n]wherenis the size
    of the target type. You must give the target type as a template argument,
    because there are multiple types with the same size and so the type of the
    argument is not enough to determine the return type. | 
| 
									bitsSet(value)
								 | Range that iterates the indices of the set bits in value.
Index 0 corresponds to the least significant bit.
For signed integers, the highest index corresponds to the sign bit. | 
| 
									littleEndianToNative(val)
								 | Converts the given value from little endian to the native endianness and
    returns it. The value is given as a ubyte[n]wherenis the size
    of the target type. You must give the target type as a template argument,
    because there are multiple types with the same size and so the type of the
    argument is not enough to determine the return type. | 
| 
									nativeToBigEndian(val)
								 | Converts the given value from the native endianness to big endian and
    returns it as a ubyte[n]wherenis the size of the given type. | 
| 
									nativeToLittleEndian(val)
								 | Converts the given value from the native endianness to little endian and
    returns it as a ubyte[n]wherenis the size of the given type. | 
| 
									peek(range)
								 | Takes a range of ubytes and converts the firstTbytes toT. The value returned is converted from the given endianness to the
    native endianness. The range is not consumed. | 
| 
									read(range)
								 | Takes a range of ubytes and converts the firstTbytes toT. The value returned is converted from the given endianness to the
    native endianness. TheTbytes which are read are consumed from
    the range. | 
| 
									swapEndian(val)
								 | Swaps the endianness of the given integral value or character. | 
| 
									write(range, value, index)
								 | Takes an integral value, converts it to the given endianness, and writes it
    to the given range of ubytes as a sequence ofTubytes
    starting at index.hasSlicing!Rmust betrue. | 
Structs
| Name | Description | 
|---|---|
| 
									BitArray
								 | A dynamic array of bits. Each bit in a BitArraycan be manipulated individually
or by the standard bitwise operators&,|,^,~,>>,<<and also by
other effective member functions; most of them work relative to theBitArray's
dimension (seedim), instead of itslength. | 
| 
									DoubleRep
								 | Allows manipulating the fraction, exponent, and sign parts of a double separately. The definition is: | 
| 
									FloatRep
								 | Allows manipulating the fraction, exponent, and sign parts of a float separately. The definition is: | 
Manifest constants
| Name | Type | Description | 
|---|---|---|
| bitfields | Allows creating bit fields inside structs and classes. | |
| taggedClassRef | This string mixin generator allows one to create tagged class reference inside structs and classes. | |
| taggedPointer | This string mixin generator allows one to create tagged pointers inside structs and classes. | 
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, Alex Rønne Petersen, Damian Ziemba, Amaury SECHET
License
					Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.