Skip to content

Instantly share code, notes, and snippets.

@jwmerrill
Created November 9, 2015 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jwmerrill/01b04dcbe7c20718bc22 to your computer and use it in GitHub Desktop.
Save jwmerrill/01b04dcbe7c20718bc22 to your computer and use it in GitHub Desktop.
Float int cast native code
julia> function fn(x1::Float64, x2::Float64)
x1_int = reinterpret(UInt64, x1)
x2_int = reinterpret(UInt64, x2)
reinterpret(Float64, (x1_int + x2_int) >> 1)
end
fn (generic function with 1 method)
julia> @code_native fn(3.0, 4.0)
.section __TEXT,__text,regular,pure_instructions
Filename: none
Source line: 2
pushq %rbp
movq %rsp, %rbp
Source line: 2
movd %xmm0, %rcx
Source line: 3
movd %xmm1, %rax
Source line: 4
addq %rcx, %rax
shrq %rax
movd %rax, %xmm0
popq %rbp
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment