TinyHugeNumbers

The TinyHugeNumbers package exports tiny and huge objects to represent tiny and huge numbers. These objects aren't really numbers — they are sentinels that promote to a concrete floating-point value before being used, which keeps computations free of unnecessary type promotions.

Supported operations are arithmetic (+, -, *, /), comparisons (<, <=, >, >=, ==, including between tiny and huge themselves), clamp, and promotion/conversion to any AbstractFloat. Generic Real fallbacks such as abs, sqrt, log, exp, the trigonometric functions, ^, zero, one, and float are not defined directly on tiny/huge — convert to a concrete float first (e.g. sqrt(tiny(Float64))). For more info see Julia's documentation about promotion.

TinyHugeNumbers.tinyConstant
tiny

tiny represents a (wow!) tiny number that can be used in a various computations without unnecessary type promotions.

tiny is defined as:

  • 1.0f-6 for Float32
  • 1e-12 for Float64
  • big"1e-24" for BigFloat
  • 10 * eps(F) for an arbitrary type F <: AbstractFloat
Note

The BigFloat value is intentionally fixed at big"1e-24" regardless of setprecision — it is meant to be a stable small floor, not to track eps(BigFloat).

Note

tiny/huge are only meaningful for floating-point types where 10 * eps(F) ≪ 1 (e.g. Float32, Float64, BigFloat). Low-precision types such as Float16 fall through to the generic 10 * eps(F) definition and produce degenerate values (tiny(Float16) ≈ 0.0098, huge(Float16) ≈ 102.4).

Example

julia> tiny
tiny

julia> 1 + tiny
1.000000000001

julia> tiny + 1
1.000000000001

julia> 1f0 + tiny
1.000001f0

julia> big"1.0" + tiny
1.000000000000000000000001

julia> big"1" + tiny
1.000000000000000000000001

See also: huge

source
TinyHugeNumbers.hugeConstant
huge

huge represents a (wow!) huge number that can be used in a various computations without unnecessary type promotions.

huge is defined as:

  • 1.0f+6 for Float32
  • 1e+12 for Float64
  • big"1e+24" for BigFloat
  • inv(tiny(F)) for an arbitrary type F <: AbstractFloat
Note

The BigFloat value is intentionally fixed at big"1e+24" regardless of setprecision — it is meant to be a stable large ceiling, not to track eps(BigFloat).

Note

tiny/huge are only meaningful for floating-point types where 10 * eps(F) ≪ 1 (e.g. Float32, Float64, BigFloat). Low-precision types such as Float16 fall through to the generic inv(tiny(F)) definition and produce degenerate values (huge(Float16) ≈ 102.4 — not "huge" at all).

Example

julia> huge
huge

julia> 1 + huge
1.000000000001e12

julia> huge + 1
1.000000000001e12

julia> 1f0 + huge
1.000001f6

julia> big"1.0" + huge
1.000000000000000000000001e+24

julia> big"1" + huge
1.000000000000000000000001e+24

See also: tiny

source