diff options
author | Fabian Keller <bluenote10@users.noreply.github.com> | 2017-10-30 17:21:44 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-30 17:21:44 +0100 |
commit | badba83d38371726bafba5870d5fb927eb453e41 (patch) | |
tree | 302458daed6184b13e952112119fc43d30523305 | |
parent | 08950649839c1df1504d495fccfea04bf11f55ed (diff) | |
download | Nim-badba83d38371726bafba5870d5fb927eb453e41.tar.gz |
Implementation of high/low for SomeReal (#6570)
-rw-r--r-- | lib/system.nim | 3 | ||||
-rw-r--r-- | tests/system/tsystem_misc.nim | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index eefad5e9c..7e0ba4658 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2076,6 +2076,9 @@ proc max*[T](x, y: T): T = if y <= x: x else: y {.pop.} +proc high*(T: typedesc[SomeReal]): T = Inf +proc low*(T: typedesc[SomeReal]): T = NegInf + proc clamp*[T](x, a, b: T): T = ## limits the value ``x`` within the interval [a, b] ## diff --git a/tests/system/tsystem_misc.nim b/tests/system/tsystem_misc.nim new file mode 100644 index 000000000..66b789ee9 --- /dev/null +++ b/tests/system/tsystem_misc.nim @@ -0,0 +1,18 @@ +discard """ + output:"" +""" + +# check high/low implementations +doAssert high(int) > low(int) +doAssert high(int8) > low(int8) +doAssert high(int16) > low(int16) +doAssert high(int32) > low(int32) +doAssert high(int64) > low(int64) +# doAssert high(uint) > low(uint) # reconsider depending on issue #6620 +doAssert high(uint8) > low(uint8) +doAssert high(uint16) > low(uint16) +doAssert high(uint32) > low(uint32) +# doAssert high(uint64) > low(uint64) # reconsider depending on issue #6620 +doAssert high(float) > low(float) +doAssert high(float32) > low(float32) +doAssert high(float64) > low(float64) |