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) {...@@ -21,6 +21,10 @@ pub fn trunc(x: anytype) @TypeOf(x) {
21 f32 => trunc32(x),21 f32 => trunc32(x),
22 f64 => trunc64(x),22 f64 => trunc64(x),
23 f128 => trunc128(x),23 f128 => trunc128(x),
24
25 // TODO this is not correct for some targets
26 c_longdouble => @floatCast(c_longdouble, trunc128(x)),
27
24 else => @compileError("trunc not implemented for " ++ @typeName(T)),28 else => @compileError("trunc not implemented for " ++ @typeName(T)),
25 };29 };
26}30}
lib/std/special/c_stage1.zig+7
...@@ -763,6 +763,13 @@ export fn truncf(a: f32) f32 {...@@ -763,6 +763,13 @@ export fn truncf(a: f32) f32 {
763 return math.trunc(a);763 return math.trunc(a);
764}764}
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
766export fn round(a: f64) f64 {773export fn round(a: f64) f64 {
767 return math.round(a);774 return math.round(a);
768}775}