Skip to content

Comptime float

Chung Leong edited this page Apr 24, 2024 · 2 revisions

In the Zig language, comptime float is the type used for numeric literals with decimal places. In JavaScript, it's represented as number like all float types. Floating pointer numbers with greater precision than f64 will experience precision loss.

const std = @import("std");

pub const pi = std.math.pi;

pub fn printPi() void {
    std.debug.print("{d}\n", .{pi});
}
import { pi, printPi } from './comptime-float-example-1.zig';

console.log(pi);
printPi();
3.141592653589793
3.1415926535897932384626433832795028

Comptime int

Clone this wiki locally