Skip to content

Commit 204f052

Browse files
committed
docs: show FRInt8 type
1 parent 650fa0f commit 204f052

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

README.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,31 +423,32 @@ julia> total_cookies = cookie_rate * total_milk
423423
92.7 cookies
424424
```
425425

426-
Exponents are tracked by default with the type `R = FixedRational{Int32,C}`,
427-
which represents rational numbers with a fixed denominator `C`.
426+
Exponents are tracked by default with the type `FRInt32` (alias for `FixedRational{Int32, 25200}`),
427+
which represents rational numbers with an integer numerator and fixed denominator.
428428
This is much faster than `Rational`.
429429

430430
```julia
431431
julia> typeof(0.5u"kg")
432-
Quantity{Float64, Dimensions{FixedRational{Int32, 25200}}}
432+
Quantity{Float64, Dimensions{FRInt32}}
433433
```
434434

435435
You can change the type of the value field by initializing with a value
436436
explicitly of the desired type.
437437

438438
```julia
439439
julia> typeof(Quantity(Float16(0.5), mass=1, length=1))
440-
Quantity{Float16, Dimensions{FixedRational{Int32, 25200}}}
440+
Quantity{Float16, Dimensions{FRInt32}}
441441
```
442442

443443
or by conversion:
444444

445445
```julia
446446
julia> typeof(convert(Quantity{Float16}, 0.5u"m/s"))
447-
Quantity{Float16, Dimensions{FixedRational{Int32, 25200}}}
447+
Quantity{Float16, Dimensions{FRInt32}}
448448
```
449449

450-
For many applications, `FixedRational{Int8,6}` will suffice,
450+
For many applications, using `FRInt8` (alias for `FixedRational{Int8,12}`)
451+
will suffice as the base dimensions type,
451452
and can be faster as it means the entire `Dimensions`
452453
struct will fit into 64 bits.
453454
You can change the type of the dimensions field by passing
@@ -456,13 +457,9 @@ the type you wish to use as the second argument to `Quantity`:
456457
```julia
457458
julia> using DynamicQuantities
458459

459-
julia> R8 = Dimensions{FixedRational{Int8,6}};
460+
julia> q8 = [Quantity{Float64,FRInt8}(randn(), length=rand(-2:2)) for i in 1:1000];
460461

461-
julia> R32 = Dimensions{FixedRational{Int32,2^4 * 3^2 * 5^2 * 7}}; # Default
462-
463-
julia> q8 = [Quantity{Float64,R8}(randn(), length=rand(-2:2)) for i in 1:1000];
464-
465-
julia> q32 = [Quantity{Float64,R32}(randn(), length=rand(-2:2)) for i in 1:1000];
462+
julia> q32 = [Quantity{Float64,FRInt32}(randn(), length=rand(-2:2)) for i in 1:1000];
466463

467464
julia> f(x) = @. x ^ 2 * 0.5;
468465

docs/src/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,7 @@ Filter = t -> !(t in [ustrip, dimension, ulength, umass, utime, ucurrent, utemp
3434

3535
```@docs
3636
FixedRational
37+
FRInt32
38+
FRInt8
3739
DynamicQuantities.denom
3840
```

0 commit comments

Comments
 (0)