ref: 96cb72770eb9c9bf3259ebb4647ef88092438808
dir: /lib/math/test/fpmath-trunc-impl.myr/
use std use math use testr const main = { testr.run([ [.name = "trunc-01", .fn = trunc01], [.name = "trunc-02", .fn = trunc02], [.name = "floor-01", .fn = floor01], [.name = "floor-02", .fn = floor02], [.name = "ceil-01", .fn = ceil01], [.name = "ceil-02", .fn = ceil02], ][:]) } impl std.equatable flt32 = eq = {a : flt32, b : flt32; -> std.flt32bits(a) == std.flt32bits(b)} ;; impl std.equatable flt64 = eq = {a : flt64, b : flt64; -> std.flt64bits(a) == std.flt64bits(b)} ;; const trunc01 = {c var flt32s : (flt32, flt32)[:] = [ (0.0, 0.0), (-0.0, -0.0), (1.0, 1.0), (1.1, 1.0), (0.9, 0.0), (10664524000000000000.0, 10664524000000000000.0), (-3.5, -3.0), (101.999, 101.0), (std.flt32nan(), std.flt32nan()), ][:] for (f, g) : flt32s testr.eq(c, math.trunc(f), g) ;; } const trunc02 = {c var flt64s : (flt64, flt64)[:] = [ (0.0, 0.0), (-0.0, -0.0), (1.0, 1.0), (1.1, 1.0), (0.9, 0.0), (13809453812721350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0, 13809453812721350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0), (-3.5, -3.0), (101.999, 101.0), (std.flt64nan(), std.flt64nan()), ][:] for (f, g) : flt64s testr.eq(c, math.trunc(f), g) ;; } const floor01 = {c var flt32s : (flt32, flt32)[:] = [ (0.0, 0.0), (-0.0, -0.0), (0.5, 0.0), (1.1, 1.0), (10664524000000000000.0, 10664524000000000000.0), (-3.5, -4.0), (-101.999, -102.0), (std.flt32nan(), std.flt32nan()), ][:] for (f, g) : flt32s testr.eq(c, math.floor(f), g) ;; } const floor02 = {c var flt64s : (flt64, flt64)[:] = [ (0.0, 0.0), (-0.0, -0.0), (0.5, 0.0), (1.1, 1.0), (13809453812721350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0, 13809453812721350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0), (-3.5, -4.0), (-101.999, -102.0), (std.flt64nan(), std.flt64nan()), ][:] for (f, g) : flt64s testr.eq(c, math.floor(f), g) ;; } const ceil01 = {c var flt32s : (flt32, flt32)[:] = [ (0.0, 0.0), (-0.0, -0.0), (0.5, 1.0), (-0.1, -0.0), (1.1, 2.0), (10664524000000000000.0, 10664524000000000000.0), (-3.5, -3.0), (-101.999, -101.0), (std.flt32nan(), std.flt32nan()), ][:] for (f, g) : flt32s testr.eq(c, math.ceil(f), g) ;; } const ceil02 = {c var flt64s : (flt64, flt64)[:] = [ (0.0, 0.0), (-0.0, -0.0), (0.5, 1.0), (-0.1, -0.0), (1.1, 2.0), (13809453812721350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0, 13809453812721350000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0), (-3.5, -3.0), (-101.999, -101.0), (std.flt64nan(), std.flt64nan()), ][:] for (f, g) : flt64s testr.eq(c, math.ceil(f), g) ;; }