stdlib: more consistent formatting

This commit is contained in:
Araq 2019-05-21 00:50:02 +02:00 • committed by Andreas Rumpf
commit 11fca968b2
2 changed files with 27 additions and 27 deletions

View file

@ -125,59 +125,59 @@ const
DBL_MAX = 1.7976931348623157E+308 ## the minimal value of a double DBL_MAX = 1.7976931348623157E+308 ## the minimal value of a double
DBL_EPSILON = 2.2204460492503131E-16 ## the difference between 1 and the least value greater than 1 of a double DBL_EPSILON = 2.2204460492503131E-16 ## the difference between 1 and the least value greater than 1 of a double
template fpRadix* : int = FLT_RADIX template fpRadix*: int = FLT_RADIX
## The (integer) value of the radix used to represent any floating ## The (integer) value of the radix used to represent any floating
## point type on the architecture used to build the program. ## point type on the architecture used to build the program.
template mantissaDigits*(T : typedesc[float32]) : int = FLT_MANT_DIG template mantissaDigits*(T: typedesc[float32]): int = FLT_MANT_DIG
## Number of digits (in base ``floatingPointRadix``) in the mantissa ## Number of digits (in base ``floatingPointRadix``) in the mantissa
## of 32-bit floating-point numbers. ## of 32-bit floating-point numbers.
template digits*(T : typedesc[float32]) : int = FLT_DIG template digits*(T: typedesc[float32]): int = FLT_DIG
## Number of decimal digits that can be represented in a ## Number of decimal digits that can be represented in a
## 32-bit floating-point type without losing precision. ## 32-bit floating-point type without losing precision.
template minExponent*(T : typedesc[float32]) : int = FLT_MIN_EXP template minExponent*(T: typedesc[float32]): int = FLT_MIN_EXP
## Minimum (negative) exponent for 32-bit floating-point numbers. ## Minimum (negative) exponent for 32-bit floating-point numbers.
template maxExponent*(T : typedesc[float32]) : int = FLT_MAX_EXP template maxExponent*(T: typedesc[float32]): int = FLT_MAX_EXP
## Maximum (positive) exponent for 32-bit floating-point numbers. ## Maximum (positive) exponent for 32-bit floating-point numbers.
template min10Exponent*(T : typedesc[float32]) : int = FLT_MIN_10_EXP template min10Exponent*(T: typedesc[float32]): int = FLT_MIN_10_EXP
## Minimum (negative) exponent in base 10 for 32-bit floating-point ## Minimum (negative) exponent in base 10 for 32-bit floating-point
## numbers. ## numbers.
template max10Exponent*(T : typedesc[float32]) : int = FLT_MAX_10_EXP template max10Exponent*(T: typedesc[float32]): int = FLT_MAX_10_EXP
## Maximum (positive) exponent in base 10 for 32-bit floating-point ## Maximum (positive) exponent in base 10 for 32-bit floating-point
## numbers. ## numbers.
template minimumPositiveValue*(T : typedesc[float32]) : float32 = FLT_MIN template minimumPositiveValue*(T: typedesc[float32]): float32 = FLT_MIN
## The smallest positive (nonzero) number that can be represented in a ## The smallest positive (nonzero) number that can be represented in a
## 32-bit floating-point type. ## 32-bit floating-point type.
template maximumPositiveValue*(T : typedesc[float32]) : float32 = FLT_MAX template maximumPositiveValue*(T: typedesc[float32]): float32 = FLT_MAX
## The largest positive number that can be represented in a 32-bit ## The largest positive number that can be represented in a 32-bit
## floating-point type. ## floating-point type.
template epsilon*(T : typedesc[float32]): float32 = FLT_EPSILON template epsilon*(T: typedesc[float32]): float32 = FLT_EPSILON
## The difference between 1.0 and the smallest number greater than ## The difference between 1.0 and the smallest number greater than
## 1.0 that can be represented in a 32-bit floating-point type. ## 1.0 that can be represented in a 32-bit floating-point type.
template mantissaDigits*(T : typedesc[float64]) : int = DBL_MANT_DIG template mantissaDigits*(T: typedesc[float64]): int = DBL_MANT_DIG
## Number of digits (in base ``floatingPointRadix``) in the mantissa ## Number of digits (in base ``floatingPointRadix``) in the mantissa
## of 64-bit floating-point numbers. ## of 64-bit floating-point numbers.
template digits*(T : typedesc[float64]) : int = DBL_DIG template digits*(T: typedesc[float64]): int = DBL_DIG
## Number of decimal digits that can be represented in a ## Number of decimal digits that can be represented in a
## 64-bit floating-point type without losing precision. ## 64-bit floating-point type without losing precision.
template minExponent*(T : typedesc[float64]) : int = DBL_MIN_EXP template minExponent*(T: typedesc[float64]): int = DBL_MIN_EXP
## Minimum (negative) exponent for 64-bit floating-point numbers. ## Minimum (negative) exponent for 64-bit floating-point numbers.
template maxExponent*(T : typedesc[float64]) : int = DBL_MAX_EXP template maxExponent*(T: typedesc[float64]): int = DBL_MAX_EXP
## Maximum (positive) exponent for 64-bit floating-point numbers. ## Maximum (positive) exponent for 64-bit floating-point numbers.
template min10Exponent*(T : typedesc[float64]) : int = DBL_MIN_10_EXP template min10Exponent*(T: typedesc[float64]): int = DBL_MIN_10_EXP
## Minimum (negative) exponent in base 10 for 64-bit floating-point ## Minimum (negative) exponent in base 10 for 64-bit floating-point
## numbers. ## numbers.
template max10Exponent*(T : typedesc[float64]) : int = DBL_MAX_10_EXP template max10Exponent*(T: typedesc[float64]): int = DBL_MAX_10_EXP
## Maximum (positive) exponent in base 10 for 64-bit floating-point ## Maximum (positive) exponent in base 10 for 64-bit floating-point
## numbers. ## numbers.
template minimumPositiveValue*(T : typedesc[float64]) : float64 = DBL_MIN template minimumPositiveValue*(T: typedesc[float64]): float64 = DBL_MIN
## The smallest positive (nonzero) number that can be represented in a ## The smallest positive (nonzero) number that can be represented in a
## 64-bit floating-point type. ## 64-bit floating-point type.
template maximumPositiveValue*(T : typedesc[float64]) : float64 = DBL_MAX template maximumPositiveValue*(T: typedesc[float64]): float64 = DBL_MAX
## The largest positive number that can be represented in a 64-bit ## The largest positive number that can be represented in a 64-bit
## floating-point type. ## floating-point type.
template epsilon*(T : typedesc[float64]): float64 = DBL_EPSILON template epsilon*(T: typedesc[float64]): float64 = DBL_EPSILON
## The difference between 1.0 and the smallest number greater than ## The difference between 1.0 and the smallest number greater than
## 1.0 that can be represented in a 64-bit floating-point type. ## 1.0 that can be represented in a 64-bit floating-point type.

View file

@ -646,9 +646,9 @@ when not defined(JS): # C
# this implementation was inspired by Go-lang Math.Trunc # this implementation was inspired by Go-lang Math.Trunc
proc truncImpl(f: float64): float64 = proc truncImpl(f: float64): float64 =
const const
mask : uint64 = 0x7FF mask: uint64 = 0x7FF
shift: uint64 = 64 - 12 shift: uint64 = 64 - 12
bias : uint64 = 0x3FF bias: uint64 = 0x3FF
if f < 1: if f < 1:
if f < 0: return -truncImpl(-f) if f < 0: return -truncImpl(-f)
@ -666,9 +666,9 @@ when not defined(JS): # C
proc truncImpl(f: float32): float32 = proc truncImpl(f: float32): float32 =
const const
mask : uint32 = 0xFF mask: uint32 = 0xFF
shift: uint32 = 32 - 9 shift: uint32 = 32 - 9
bias : uint32 = 0x7F bias: uint32 = 0x7F
if f < 1: if f < 1:
if f < 0: return -truncImpl(-f) if f < 0: return -truncImpl(-f)
@ -846,7 +846,7 @@ when not defined(JS):
## m. ## m.
## ##
## .. code-block:: nim ## .. code-block:: nim
## var x : int ## var x: int
## echo frexp(5.0, x) # 0.625 ## echo frexp(5.0, x) # 0.625
## echo x # 3 ## echo x # 3
var exp: int32 var exp: int32