aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/bigfloat.cpp
diff options
context:
space:
mode:
authorTakeshi Yoneda <takeshi@tetrate.io>2021-08-09 14:39:26 +0900
committerTakeshi Yoneda <takeshi@tetrate.io>2021-08-09 14:39:26 +0900
commit97560cd915008f04addc2c30af087aa89c162b02 (patch)
tree8aed12c207ff84cc256a0c78955c23b61129ba22 /src/stage1/bigfloat.cpp
parent7814a2bd4a3ec22cd9548c622f7dc837dba968f7 (diff)
parent799fedf612aa8742c446b015c12d21707a1dbec0 (diff)
downloadzig-97560cd915008f04addc2c30af087aa89c162b02.tar.gz
zig-97560cd915008f04addc2c30af087aa89c162b02.zip
Merge remote-tracking branch 'origin' into libc-wasi-test
Diffstat (limited to 'src/stage1/bigfloat.cpp')
-rw-r--r--src/stage1/bigfloat.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/stage1/bigfloat.cpp b/src/stage1/bigfloat.cpp
index 56bf2637e3..e5f21e34ea 100644
--- a/src/stage1/bigfloat.cpp
+++ b/src/stage1/bigfloat.cpp
@@ -191,6 +191,30 @@ void bigfloat_sqrt(BigFloat *dest, const BigFloat *op) {
f128M_sqrt(&op->value, &dest->value);
}
+void bigfloat_min(BigFloat *dest, const BigFloat *op1, const BigFloat *op2) {
+ if (bigfloat_is_nan(op1)) {
+ bigfloat_init_bigfloat(dest, op2);
+ } else if (bigfloat_is_nan(op2)) {
+ bigfloat_init_bigfloat(dest, op1);
+ } else if (f128M_lt(&op1->value, &op2->value)) {
+ bigfloat_init_bigfloat(dest, op1);
+ } else {
+ bigfloat_init_bigfloat(dest, op2);
+ }
+}
+
+void bigfloat_max(BigFloat *dest, const BigFloat *op1, const BigFloat *op2) {
+ if (bigfloat_is_nan(op1)) {
+ bigfloat_init_bigfloat(dest, op2);
+ } else if (bigfloat_is_nan(op2)) {
+ bigfloat_init_bigfloat(dest, op1);
+ } else if (f128M_lt(&op1->value, &op2->value)) {
+ bigfloat_init_bigfloat(dest, op2);
+ } else {
+ bigfloat_init_bigfloat(dest, op1);
+ }
+}
+
bool bigfloat_is_nan(const BigFloat *op) {
return f128M_isSignalingNaN(&op->value);
}