mirror of
https://github.com/status-im/nim-stew.git
synced 2025-01-09 11:45:42 +00:00
9 lines
254 B
Nim
9 lines
254 B
Nim
## This module may hold various saturating arithmetic definitions.
|
|
## It will be expanded on demand as Status project require its definition
|
|
|
|
func saturate*(T: type int64, u: uint64): T =
|
|
if u > high(int64).uint64:
|
|
high(int64)
|
|
else:
|
|
int64(u)
|