File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Expand file tree Collapse file tree 1 file changed +26
-3
lines changed Original file line number Diff line number Diff line change @@ -288,9 +288,32 @@ true
288
288
289
289
## Types
290
290
291
- Both a ` Quantity ` 's values and dimensions are of arbitrary type.
292
- By default, dimensions are stored as a ` Dimensions{FixedRational{Int32,C}} `
293
- object, whose exponents are stored as rational numbers
291
+ Both a ` Quantity ` 's values and dimensions are of arbitrary type. The default
292
+ ` Dimensions ` (for the ` u"..." ` macro) performs exponent tracking for SI units,
293
+ and ` SymbolicDimensions ` (for the ` us"..." ` macro) performs exponent tracking
294
+ for all known unit and constant symbols, using a sparse array.
295
+
296
+ You can create custom spaces dimension spaces by simply creating
297
+ a Julia struct subtyped to ` AbstractDimensions ` :
298
+
299
+ ``` julia
300
+ julia> struct CookiesAndMilk{R} <: AbstractDimensions{R}
301
+ cookies:: R
302
+ milk:: R
303
+ end
304
+
305
+ julia> cookie_rate = Quantity (0.9 , CookiesAndMilk (cookies= 1 , milk= - 1 ))
306
+ 0.9 cookies milk⁻¹
307
+
308
+ julia> total_milk = Quantity (103 , CookiesAndMilk (milk= 1 ))
309
+ 103 milk
310
+
311
+ julia> total_cookies = cookie_rate * total_milk
312
+ 92.7 cookies
313
+ ```
314
+
315
+ Exponents are tracked with the ` FixedRational{Int32,C}} `
316
+ object, which represents rational numbers
294
317
with a fixed denominator ` C ` . This is much faster than ` Rational ` .
295
318
296
319
``` julia
You can’t perform that action at this time.
0 commit comments