diff options
| author | Takeshi Yoneda <takeshi@tetrate.io> | 2021-08-09 14:39:26 +0900 |
|---|---|---|
| committer | Takeshi Yoneda <takeshi@tetrate.io> | 2021-08-09 14:39:26 +0900 |
| commit | 97560cd915008f04addc2c30af087aa89c162b02 (patch) | |
| tree | 8aed12c207ff84cc256a0c78955c23b61129ba22 /src/stage1/bigfloat.cpp | |
| parent | 7814a2bd4a3ec22cd9548c622f7dc837dba968f7 (diff) | |
| parent | 799fedf612aa8742c446b015c12d21707a1dbec0 (diff) | |
| download | zig-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.cpp | 24 |
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); } |
