# Is the least significant bit from bitstring() correct?

**URL:** <https://discourse.julialang.org/t/is-the-least-significant-bit-from-bitstring-correct/74206>\
**Category:** General Usage\
**Tags:** question, bug, numbers, bitstring\
**Created:** [January 7, 2022, 6:17pm UTC](https://discourse.julialang.org/t/is-the-least-significant-bit-from-bitstring-correct/74206 "2022-01-07T18:17:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![g2g](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@g2g](https://discourse.julialang.org/u/g2g)\
**Post date:** [January 7, 2022, 6:17pm UTC](https://discourse.julialang.org/t/is-the-least-significant-bit-from-bitstring-correct/74206/1 "2022-01-07T18:17:08Z")

</div>

I don’t know if this is a bug but it isn’t what I was expecting:

```julia
julia> bitstring(Float32(0.777777777777777777777777777777777777777777777777))
"00111111010001110001110001110010"

julia> bitstring(Float64(0.777777777777777777777777777777777777777777777777))
"0011111111101000111000111000111000111000111000111000111000111001"

```

Shouldn’t the least significant bit of the Float32 encoding be a 1 and the least significant bit of the Float64 encoding by a 0 to capture the 000111… pattern? (Also, the next to least significant bit of the Float32 encoding appears to be flipped.)

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [January 7, 2022, 6:36pm UTC](https://discourse.julialang.org/t/is-the-least-significant-bit-from-bitstring-correct/74206/2 "2022-01-07T18:36:28Z")

</div>

This is just rounding. It’s kinda like a plain old decimal representation of \frac{1}{101} = 0.\overline{0099}. If you limit that repeating 0.009900990099\dots to 7 decimal places, it rounds to: 0.0099010. That’s exactly what’s happening here: \frac{7}{9} is similarly a repeating fraction in both decimal and binary and it’s gotta snap to the nearest representable value at some point.
