You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,7 +73,7 @@ This package also adds a saturating mode, where values accumulate at the maximum
73
73
# Evaluates to `typemax(Int64)`
74
74
```
75
75
76
-
Broadcasted operators/methods and elementwise array operators, and assignment operators are also rewritten:
76
+
Broadcasted operators/methods, elementwise array operators, and assignment operators are also rewritten:
77
77
```julia
78
78
@checked.-fill(typemin(Int64), 2)
79
79
# Expands to `OverflowContexts.checked_neg.(fill(typemin(Int64), 2))`
@@ -89,7 +89,7 @@ a = fill(1, 2)
89
89
# Evaluates to `[typemax(Int64), typemax(Int64)]`
90
90
```
91
91
92
-
Functions passed as an argument are also rewritten:
92
+
Functions passed as an argument are also supported:
93
93
```julia
94
94
@saturatingmap(-, fill(typemin(Int64), 2))
95
95
# Expands to `map(OverflowContexts.saturating_neg, fill(typemin(Int64), 2))`
@@ -103,7 +103,7 @@ Julia has a more complex `div` API than is supported here (e.g. supporting round
103
103
104
104
## Module Default Macros
105
105
106
-
If you are writing a module and desire to set the default type of arithemtic for the module, place e.g., `@default_unchecked`, `@default_checked`, `@default_saturating` at the top of the module. This macro defines module-local copies of all of the supported arithemtic operators and methods, mapping them to the appropriate `checked_` or `saturating_` methods. The defaults do not affect anything inside the expression/block-level macros. These defaults may also be used on the REPL to switch between modes, although keep in mind that it will also cause previous methods defined on the REPL (in the `Main` module) to be recompiled with the new default.
106
+
If you are writing a module and desire to set the default type of arithemtic for the module, place e.g., `@default_unchecked`, `@default_checked`, `@default_saturating` at the top of the module. This macro defines module-local copies of all of the supported arithemtic operators and methods, mapping them to the appropriate `unchecked`, `checked_`, or `saturating_` methods. The defaults do not affect anything inside the expression/block-level macros. These defaults may also be used on the REPL to switch between modes, although keep in mind that it will also cause previous methods defined on the REPL (in the `Main` module) to be recompiled with the new default.
107
107
```julia
108
108
module Foo
109
109
using OverflowContexts
@@ -119,7 +119,7 @@ Foo.baz(typemax(Int64), 1)
119
119
120
120
# Custom Numeric Types Support
121
121
122
-
If you are implementing your own `Number` types, this package should just work for you so long as you extend the Base operators and the Base.Checked `checked_` methods. For `saturating_`, your package will need to either take OverflowContexts as a dependency or a weak dependency in order to import the `saturating_` methods, until/unless Julia implements them directly.
122
+
If you are implementing your own `Number` types, this package should just work for you so long as you extend the Base operators and the Base.Checked `checked_` methods. For `saturating_`, your package will need to either take OverflowContexts as a dependency or a weak dependency with a package extension in order to import the `saturating_` methods, until/unless Julia implements them directly.
0 commit comments