Skip to content

Commit

Permalink
Added README and final touches for now
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaMorphic committed Aug 14, 2023
1 parent e17dc35 commit 8a277b8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
28 changes: 28 additions & 0 deletions QuadrupleLib/Float128.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,34 @@ public static Float128 Floor(Float128 value)
return result;
}

public static Float128 Ceiling(Float128 value)
{
Float128 result;
int unbiasedExponent = value.Exponent;

if (unbiasedExponent == short.MaxValue) result = value; //NaN, +inf, -inf
else if (unbiasedExponent < 0)
{
if (value.RawSignBit)
{
result = 0;
}
else
{
result = 1;
}
}
else
{
result = value;
int bitsToErase = 112 - unbiasedExponent;
result.RawSignificand &= ~((UInt128.One << bitsToErase) - 1);
if (value.RawSignBit) result += 1;
}

return result;
}

#endregion

#region Public API (complex number related)
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# QuadrupleLib

QuadrupleLib is a modern implementation of the IEEE 754 `binary128` floating point number type for .NET 7 and above based on the `UInt128` built-in. The goal of this project is to eventually create a fully fleshed out 128-bit floating point arithmetic library that includes all of the bells and whistles one could possibly want.

### Project TODOs

- [x] Adheres to minimum requirements of IEEE 754 specification
- [x] Partially implements .NET 7 `ISignedNumber` generic arithmetic interface
- [x] Implements all basic arithmetic operations (`+`, `-`, `*`, `/`, `%`, `++`, `--`)
- [x] Implements all standard rounding functions (`Round`, `Floor`, `Ceiling`)
- [x] Implements basic `ToString` and `Parse`/`TryParse` methods
- [x] Implements conversion methods to & from `binary64` type
- [x] Provides conversion pathways to all standard .NET number types via `binary64`
- [ ] Implements `IEEERemainder` as suggested in IEEE 754
- [ ] Implements typical library functions (`Pow`, `Atan2`, `Log`)
- [ ] Supports all rounding modes (atm only implements "ties to even" mode)
- [ ] Supports .NET Core formatting features for `ToString` and `Parse`
- [ ] Implements .NET 7 `IBinaryFloatingPointIeee754` generic arithmetic interface

0 comments on commit 8a277b8

Please sign in to comment.