Skip to content

Commit b3b3760

Browse files
Deprecate saturating_arith and saturation_arith (#266)
* Depracate saturating_arith and saturation_arith. * Update stew/saturating_arith.nim Co-authored-by: Jacek Sieka <jacek@status.im> * saturation_arith: Add intops link in the deprecation notice. --------- Co-authored-by: Jacek Sieka <jacek@status.im>
1 parent 1dc27d1 commit b3b3760

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

stew/saturating_arith.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
## This module may hold various saturating arithmetic definitions.
22
## It will be expanded on demand as more definitions are requred.
33

4+
{.deprecated: "Use https://github.com/vacp2p/nim-intops instead".}
5+
46
func saturate*(T: type int64, u: uint64): T =
7+
##[ Convert a uint64 to int64. If the value won't fit in int64,
8+
return maximal value.
9+
10+
Notice: This function is deprecated.
11+
12+
If you need to limit the value of an integer, use `clamp(a, minVal, maxVal)` from stdlib.
13+
14+
If you use this function to implement saturating addition, use `saturatingAdd` from [intops](https://github.com/vacp2p/nim-intops/) library.
15+
]##
16+
517
if u > high(int64).uint64:
618
high(int64)
719
else:

stew/saturation_arith.nim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
## This module may hold various saturating arithmetic definitions.
22
## It will be expanded on demand as Status project require its definition
33

4+
{.deprecated: "Use https://github.com/vacp2p/nim-intops instead".}
5+
46
func saturate*(T: type int64, u: uint64): T =
7+
##[ Convert a uint64 to int64. If the value won't fit in int64,
8+
return maximal value.
9+
10+
Notice: This function is deprecated.
11+
12+
If you need to limit the value of an integer, use `clamp(a, minVal, maxVal)` from stdlib.
13+
14+
If you use this function to implement saturating addition, use `saturatingAdd` from [intops](https://github.com/vacp2p/nim-intops/) library.
15+
]##
16+
517
if u > high(int64).uint64:
618
high(int64)
719
else:

0 commit comments

Comments
 (0)