Skip to content

Commit

Permalink
Expand README
Browse files Browse the repository at this point in the history
  • Loading branch information
depp committed May 27, 2022
1 parent 3c85699 commit e7823c8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
# 80-bit Extended-Precision Floating-Point Numbers

This is a Go library that provides a type for representing 80-bit extended-precision floating-point numbers. It is licensed under the terms of the MIT license, see [LICENSE.txt](LICENSE.txt) for details.

## Example

```
package main
import (
"fmt"
"github.com/depp/extended"
)
func main() {
e := extended.Extended{
SignExponent: 0x3fff,
Fraction: 0xC000000000000000,
}
// Prints "Value: 1.5"
fmt.Println("Value:", e.Float64())
}
```

## Rounding, Infinity, and NaN

This library uses round-to-even when converting from 80-bit floats to 64-bit floats. This should be what you’re used to, and what you expect! In round-to-even, when an 80-bit float is exactly half-way between two possible `float64` values, the value with a zero in the least-significant bit is chosen (or the value with the larger exponent is chosen, if the values have different exponents).

Values which are outside the range of possible `float64` values are rounded to infinity.

Infinity and NaN are preserved. Different types of NaN values are not distinguished from each other, but the sign of NaN values is preserved during conversion.

0 comments on commit e7823c8

Please sign in to comment.