minimum/maximum builtins
This commit is contained in:
committed by
Andrew Kelley
parent
50a29f7c21
commit
cdeea3b094
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user