Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitCast to and from array #421

Closed
andrewrk opened this issue Aug 18, 2017 · 1 comment
Closed

bitCast to and from array #421

andrewrk opened this issue Aug 18, 2017 · 1 comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Aug 18, 2017

const assert = @import("std").debug.assert;

test "bitCast to array" {
    comptime testBitCastArray();
    testBitCastArray();
}

fn testBitCastArray() void {
    assert(extractOne64(0x0123456789abcdef0123456789abcdef) == 0x0123456789abcdef);
}

fn extractOne64(a: u128) u64 {
    const x = @bitCast([2]u64, a);
    return x[1];
}
@andrewrk andrewrk added the enhancement Solving this issue will likely involve adding new logic or components to the codebase. label Aug 18, 2017
@andrewrk andrewrk added this to the 0.2.0 milestone Aug 18, 2017
@thejoshwolfe
Copy link
Sponsor Contributor

endianness is relevant here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase.
Projects
None yet
Development

No branches or pull requests

2 participants