Skip to content

Commit dfc102e

Browse files
committed
Updated readme with construction
1 parent 79d85b4 commit dfc102e

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ The operations possible with these types can be divided into two categories:
2828

2929
Like standard C(++) types, the fixed point numbers defined here are following some rules:
3030
- any fixed type can be converted to another *as long as the value can be represented in the destination type*. Casting to a bigger type in term of NI and NF is safe, but reducing NI can lead to an overflow if the new type cannot hold the integer value and reducing NF leads to a loss of precision.
31-
- Fixed types can be constructed from and converted to standard C types.
31+
- Fixed types can be constructed from and converted to standard C types:
32+
- `UFix<NI,NF>(T value)` will convert the `value` to a `UFix`. If T is an integer type the final number will have a fractional part equal to zero. This can be used as a standard type, for example: `UFix<8,8> a = 15;` or `UFix<8,8> b = 200.25;`
33+
- same for `SFix`
34+
- `UFix<NI,NF>::fromRaw(T value)` will set the *internal* value of the `UFix`. For example `UFix<7,1>::fromRaw(16);` is actually 8
35+
- same for `SFix`
3236
- all operations between fixed point number is safe (it won't overflow) and preserve the precision. In particular:
3337
- only addition, subtraction and multiplication are implemented (this is a design choice, see below)
3438
- any operation between a signed and an unsigned leads to a signed number

0 commit comments

Comments
 (0)