| author | |
| committer | |
| log | 2a733051bb5da245ac377f8771a482a85fb88519 |
| tree | 54e423d7053945cadb7a76a3af46baf64e9f817f |
| parent | 811766e1cf0ad2fad73fbb82690969ce430ba1a5 |
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 | 21 | f32 => trunc32(x), |
| 22 | 22 | f64 => trunc64(x), |
| 23 | 23 | f128 => trunc128(x), |
| 24 | ||
| 25 | // TODO this is not correct for some targets | |
| 26 | c_longdouble => @floatCast(c_longdouble, trunc128(x)), | |
| 27 | ||
| 24 | 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 | 763 | return math.trunc(a); |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | export 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 | ||
| 766 | 773 | export fn round(a: f64) f64 { |
| 767 | 774 | return math.round(a); |
| 768 | 775 | } |