Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions double/README.mbt.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test "special value testing" {

## Binary Representation

Functions for converting doubles to their binary representation:
To convert doubles to their binary representation, use `@buffer` instead:

```mbt check
///|
Expand All @@ -79,14 +79,19 @@ test "binary representation" {

// Convert to big-endian and little-endian bytes
// Different byte orders should produce different results
let buffer = @buffer.new()
buffer.write_double_be(num)
inspect(
num.to_be_bytes_local(),
buffer.to_bytes(),
content=(
#|b"?\xf0\x00\x00\x00\x00\x00\x00"
),
)

buffer.reset()
buffer.write_double_le(num)
inspect(
num.to_le_bytes_local(),
buffer.to_bytes(),
content=(
#|b"\x00\x00\x00\x00\x00\x00\xf0?"
),
Expand Down
Loading