Method WriteToBytes
WriteToBytes(ref Span<Byte>)
Copies the value of this BigRational as little-endian twos-complement bytes.
If the value is zero, outputs one uint whose element is 0x00000000.
Declaration
public int WriteToBytes(ref Span<byte> destination)
Parameters
Type | Name | Description |
---|---|---|
System.Span<System.Byte> | destination | The destination span to which the resulting bytes should be written. |
Returns
Type | Description |
---|---|
System.Int32 | The number of bytes written or required in case of an empty or undersized destination. |
Remarks
The destination Span will get the offset of the number of bytes written.
In case of undersized destination, as signal the span is reset to default.
This allows efficient code in serialization sequences.
Examples
X.WriteToBytes(ref dest);
Y.WriteToBytes(ref dest);
Z.WriteToBytes(ref dest);
if(dest == default) return false; //undersized destination