rename SomeReal to SomeFloat (#7617)
* rename SomeReal to SomeFloat * added changelog entry
This commit is contained in:
parent
b98cd3bf34
commit
efae366857
6 changed files with 38 additions and 34 deletions
|
|
@ -26,33 +26,33 @@
|
|||
|
||||
import typetraits
|
||||
|
||||
proc `+`*[I: SomeInteger, F: SomeReal](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
proc `+`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
F(i) + f
|
||||
proc `+`*[I: SomeInteger, F: SomeReal](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
proc `+`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
f + F(i)
|
||||
|
||||
proc `-`*[I: SomeInteger, F: SomeReal](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
proc `-`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
F(i) - f
|
||||
proc `-`*[I: SomeInteger, F: SomeReal](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
proc `-`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
f - F(i)
|
||||
|
||||
proc `*`*[I: SomeInteger, F: SomeReal](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
proc `*`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
F(i) * f
|
||||
proc `*`*[I: SomeInteger, F: SomeReal](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
proc `*`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
f * F(i)
|
||||
|
||||
proc `/`*[I: SomeInteger, F: SomeReal](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
proc `/`*[I: SomeInteger, F: SomeFloat](i: I, f: F): F {.noSideEffect, inline.} =
|
||||
F(i) / f
|
||||
proc `/`*[I: SomeInteger, F: SomeReal](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
proc `/`*[I: SomeInteger, F: SomeFloat](f: F, i: I): F {.noSideEffect, inline.} =
|
||||
f / F(i)
|
||||
|
||||
proc `<`*[I: SomeInteger, F: SomeReal](i: I, f: F): bool {.noSideEffect, inline.} =
|
||||
proc `<`*[I: SomeInteger, F: SomeFloat](i: I, f: F): bool {.noSideEffect, inline.} =
|
||||
F(i) < f
|
||||
proc `<`*[I: SomeInteger, F: SomeReal](f: F, i: I): bool {.noSideEffect, inline.} =
|
||||
proc `<`*[I: SomeInteger, F: SomeFloat](f: F, i: I): bool {.noSideEffect, inline.} =
|
||||
f < F(i)
|
||||
proc `<=`*[I: SomeInteger, F: SomeReal](i: I, f: F): bool {.noSideEffect, inline.} =
|
||||
proc `<=`*[I: SomeInteger, F: SomeFloat](i: I, f: F): bool {.noSideEffect, inline.} =
|
||||
F(i) <= f
|
||||
proc `<=`*[I: SomeInteger, F: SomeReal](f: F, i: I): bool {.noSideEffect, inline.} =
|
||||
proc `<=`*[I: SomeInteger, F: SomeFloat](f: F, i: I): bool {.noSideEffect, inline.} =
|
||||
f <= F(i)
|
||||
|
||||
# Note that we must not defined `>=` and `>`, because system.nim already has a
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ type
|
|||
## ``parseStandardFormatSpecifier`` returned.
|
||||
|
||||
proc formatInt(n: SomeNumber; radix: int; spec: StandardFormatSpecifier): string =
|
||||
## Converts ``n`` to string. If ``n`` is `SomeReal`, it casts to `int64`.
|
||||
## Converts ``n`` to string. If ``n`` is `SomeFloat`, it casts to `int64`.
|
||||
## Conversion is done using ``radix``. If result's length is lesser than
|
||||
## ``minimumWidth``, it aligns result to the right or left (depending on ``a``)
|
||||
## with ``fill`` char.
|
||||
|
|
@ -503,8 +503,8 @@ proc format*(value: SomeInteger; specifier: string; res: var string) =
|
|||
" of 'x', 'X', 'b', 'd', 'o' but got: " & spec.typ)
|
||||
res.add formatInt(value, radix, spec)
|
||||
|
||||
proc format*(value: SomeReal; specifier: string; res: var string) =
|
||||
## Standard format implementation for ``SomeReal``. It makes little
|
||||
proc format*(value: SomeFloat; specifier: string; res: var string) =
|
||||
## Standard format implementation for ``SomeFloat``. It makes little
|
||||
## sense to call this directly, but it is required to exist
|
||||
## by the ``&`` macro.
|
||||
let spec = parseStandardFormatSpecifier(specifier)
|
||||
|
|
@ -678,4 +678,4 @@ when isMainModule:
|
|||
|
||||
doAssert fmt"{'a'} {'b'}" == "a b"
|
||||
|
||||
echo("All tests ok")
|
||||
echo("All tests ok")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue