Skip to content

Instantly share code, notes, and snippets.

@andrewrk
Created August 19, 2017 21:47
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 andrewrk/4183a508264800d0c0fc546c168e0d75 to your computer and use it in GitHub Desktop.
Save andrewrk/4183a508264800d0c0fc546c168e0d75 to your computer and use it in GitHub Desktop.
[nix-shell:~/dev/zig/build]$ ./zig build_obj test2.zig
| "sin_result", 0.909297
| "fabs_result", 0.909297
| "fabs_bits", 1063831479
| "scaled_up", 3905402623.090703
| "anded", 3905402623
/home/andy/dev/zig/build/test2.zig:11:5: error: found compile log statement
@compileLog("sin_result", sin_result);
^
/home/andy/dev/zig/build/test2.zig:12:5: error: found compile log statement
@compileLog("fabs_result", fabs_result);
^
/home/andy/dev/zig/build/test2.zig:13:5: error: found compile log statement
@compileLog("fabs_bits", fabs_bits);
^
/home/andy/dev/zig/build/test2.zig:14:5: error: found compile log statement
@compileLog("scaled_up", scaled_up);
^
/home/andy/dev/zig/build/test2.zig:15:5: error: found compile log statement
@compileLog("anded", anded);
^
[nix-shell:~/dev/zig/build]$
const math = @import("std").math;
comptime {
var i: u32 = 1;
const sin_result = math.sin(f32(i+1));
const fabs_result = math.fabs( sin_result );
const fabs_bits = @bitCast(u32, fabs_result);
const scaled_up = fabs_result * @maxValue(u32);
const anded = u32( scaled_up ) & 0xFFFFFFFF;
@compileLog("sin_result", sin_result);
@compileLog("fabs_result", fabs_result);
@compileLog("fabs_bits", fabs_bits);
@compileLog("scaled_up", scaled_up);
@compileLog("anded", anded);
}
// expected value: 0xe8c7b756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment