aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/bigfloat.cpp
diff options
context:
space:
mode:
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);
}