# Fast way to access bits of Float64?

**URL:** <https://discourse.julialang.org/t/fast-way-to-access-bits-of-float64/11098>\
**Category:** General Usage\
**Created:** [May 23, 2018, 2:33pm UTC](https://discourse.julialang.org/t/fast-way-to-access-bits-of-float64/11098 "2018-05-23T14:33:47Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [May 23, 2018, 7:35pm UTC](https://discourse.julialang.org/t/fast-way-to-access-bits-of-float64/11098/4 "2018-05-23T19:35:49Z")

</div>

with this macro I copied from [here](https://discourse.julialang.org/t/defining-function-inside-a-macro/9139/4) rewritten so it works in a loop/iteration 1:64

```julia
macro make_rawbit(idx)
    fn = Symbol(string("rawbit",idx))
    quote
        function $(esc(fn))(x::Float64)
            rawbit(x, $idx)
        end
    end
 end

```

or just written 64 times

```julia
@make_rawbit(i) where i=1:64
rawbits = (rawbit1, rawbit2, .., rawbit64)

rawbits[kthbit](targetfloat64)

```

`rawbits[kthbit](targetfloat64)` compiles as `rawbitk(targetfloat64)`

---

_[View the full topic](https://discourse.julialang.org/t/fast-way-to-access-bits-of-float64/11098)._
