authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-10-24 19:17:55+02:00
committergravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2021-10-24 19:17:55+02:00
log2a733051bb5da245ac377f8771a482a85fb88519
tree54e423d7053945cadb7a76a3af46baf64e9f817f
parent811766e1cf0ad2fad73fbb82690969ce430ba1a5

libc: Export truncl

With the usual caveat of it being wrong for targets where c_longdouble is not f128.

2 files changed, 11 insertions(+), 0 deletions(-)

lib/std/math/trunc.zig+4
......@@ -21,6 +21,10 @@ pub fn trunc(x: anytype) @TypeOf(x) {
2121 f32 => trunc32(x),
2222 f64 => trunc64(x),
2323 f128 => trunc128(x),
24
25 // TODO this is not correct for some targets
26 c_longdouble => @floatCast(c_longdouble, trunc128(x)),
27
2428 else => @compileError("trunc not implemented for " ++ @typeName(T)),
2529 };
2630}
lib/std/special/c_stage1.zig+7
......@@ -763,6 +763,13 @@ export fn truncf(a: f32) f32 {
763763 return math.trunc(a);
764764}
765765
766export fn truncl(a: c_longdouble) c_longdouble {
767 if (!long_double_is_f128) {
768 @panic("TODO implement this");
769 }
770 return math.trunc(a);
771}
772
766773export fn round(a: f64) f64 {
767774 return math.round(a);
768775}