(523 lines)
1 '\" t2 .\" Copyright (c) 2025 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH Num 3 2025-11-29 "Tomo man-pages"6 .SH NAME7 Num \- a Tomo type8 .SH LIBRARY9 Tomo Standard Library10 .fi11 .SH METHODS13 .TP14 .BI Num.1_PI\ :\ Num15 The constant $\frac{1}{\pi}$.17 For more, see:18 .BR Tomo-Num.1_PI (3)21 .TP22 .BI Num.2_PI\ :\ Num23 The constant $2 \times \pi$.25 For more, see:26 .BR Tomo-Num.2_PI (3)29 .TP30 .BI Num.2_SQRTPI\ :\ Num31 The constant $2 \times \sqrt{\pi}$.33 For more, see:34 .BR Tomo-Num.2_SQRTPI (3)37 .TP38 .BI Num.E\ :\ Num39 The base of the natural logarithm ($e$).41 For more, see:42 .BR Tomo-Num.E (3)45 .TP46 .BI Num.INF\ :\ Num47 Positive infinity.49 For more, see:50 .BR Tomo-Num.INF (3)53 .TP54 .BI Num.LN10\ :\ Num55 The natural logarithm of 10.57 For more, see:58 .BR Tomo-Num.LN10 (3)61 .TP62 .BI Num.LN2\ :\ Num63 The natural logarithm of 2.65 For more, see:66 .BR Tomo-Num.LN2 (3)69 .TP70 .BI Num.LOG2E\ :\ Num71 The base 2 logarithm of $e$73 For more, see:74 .BR Tomo-Num.LOG2E (3)77 .TP78 .BI Num.PI\ :\ Num79 Pi ($\pi$).81 For more, see:82 .BR Tomo-Num.PI (3)85 .TP86 .BI Num.PI_2\ :\ Num87 $\frac{\pi}{2}$89 For more, see:90 .BR Tomo-Num.PI_2 (3)93 .TP94 .BI Num.PI_4\ :\ Num95 $\frac{\pi}{4}$97 For more, see:98 .BR Tomo-Num.PI_4 (3)101 .TP102 .BI Num.SQRT1_2\ :\ Num103 $\sqrt{\frac{1}{2}}$105 For more, see:106 .BR Tomo-Num.SQRT1_2 (3)109 .TP110 .BI Num.SQRT2\ :\ Num111 $\sqrt{2}$113 For more, see:114 .BR Tomo-Num.SQRT2 (3)117 .TP118 .BI Num.TAU\ :\ Num119 Tau ($2 \times \pi$)121 For more, see:122 .BR Tomo-Num.TAU (3)125 .TP126 .BI Num.abs\ :\ func(n:\ Num\ ->\ Num)127 Calculates the absolute value of a number.129 For more, see:130 .BR Tomo-Num.abs (3)133 .TP134 .BI Num.acos\ :\ func(x:\ Num\ ->\ Num)135 Computes the arc cosine of a number.137 For more, see:138 .BR Tomo-Num.acos (3)141 .TP142 .BI Num.acosh\ :\ func(x:\ Num\ ->\ Num)143 Computes the inverse hyperbolic cosine of a number.145 For more, see:146 .BR Tomo-Num.acosh (3)149 .TP150 .BI Num.asin\ :\ func(x:\ Num\ ->\ Num)151 Computes the arc sine of a number.153 For more, see:154 .BR Tomo-Num.asin (3)157 .TP158 .BI Num.asinh\ :\ func(x:\ Num\ ->\ Num)159 Computes the inverse hyperbolic sine of a number.161 For more, see:162 .BR Tomo-Num.asinh (3)165 .TP166 .BI Num.atan\ :\ func(x:\ Num\ ->\ Num)167 Computes the arc tangent of a number.169 For more, see:170 .BR Tomo-Num.atan (3)173 .TP174 .BI Num.atan2\ :\ func(x:\ Num,\ y:\ Num\ ->\ Num)175 Computes the arc tangent of the quotient of two numbers.177 For more, see:178 .BR Tomo-Num.atan2 (3)181 .TP182 .BI Num.atanh\ :\ func(x:\ Num\ ->\ Num)183 Computes the inverse hyperbolic tangent of a number.185 For more, see:186 .BR Tomo-Num.atanh (3)189 .TP190 .BI Num.cbrt\ :\ func(x:\ Num\ ->\ Num)191 Computes the cube root of a number.193 For more, see:194 .BR Tomo-Num.cbrt (3)197 .TP198 .BI Num.ceil\ :\ func(x:\ Num\ ->\ Num)199 Rounds a number up to the nearest integer.201 For more, see:202 .BR Tomo-Num.ceil (3)205 .TP206 .BI Num.clamped\ :\ func(x:\ Num,\ low:\ Num,\ high:\ Num\ ->\ Num)207 Returns the given number clamped between two values so that it is within that range.209 For more, see:210 .BR Tomo-Num.clamped (3)213 .TP214 .BI Num.copysign\ :\ func(x:\ Num,\ y:\ Num\ ->\ Num)215 Copies the sign of one number to another.217 For more, see:218 .BR Tomo-Num.copysign (3)221 .TP222 .BI Num.cos\ :\ func(x:\ Num\ ->\ Num)223 Computes the cosine of a number (angle in radians).225 For more, see:226 .BR Tomo-Num.cos (3)229 .TP230 .BI Num.cosh\ :\ func(x:\ Num\ ->\ Num)231 Computes the hyperbolic cosine of a number.233 For more, see:234 .BR Tomo-Num.cosh (3)237 .TP238 .BI Num.erf\ :\ func(x:\ Num\ ->\ Num)239 Computes the error function of a number.241 For more, see:242 .BR Tomo-Num.erf (3)245 .TP246 .BI Num.erfc\ :\ func(x:\ Num\ ->\ Num)247 Computes the complementary error function of a number.249 For more, see:250 .BR Tomo-Num.erfc (3)253 .TP254 .BI Num.exp\ :\ func(x:\ Num\ ->\ Num)255 Computes the exponential function $e^x$ for a number.257 For more, see:258 .BR Tomo-Num.exp (3)261 .TP262 .BI Num.exp2\ :\ func(x:\ Num\ ->\ Num)263 Computes $2^x$ for a number.265 For more, see:266 .BR Tomo-Num.exp2 (3)269 .TP270 .BI Num.expm1\ :\ func(x:\ Num\ ->\ Num)271 Computes $e^x - 1$ for a number.273 For more, see:274 .BR Tomo-Num.expm1 (3)277 .TP278 .BI Num.fdim\ :\ func(x:\ Num,\ y:\ Num\ ->\ Num)279 Computes the positive difference between two numbers.281 For more, see:282 .BR Tomo-Num.fdim (3)285 .TP286 .BI Num.floor\ :\ func(x:\ Num\ ->\ Num)287 Rounds a number down to the nearest integer.289 For more, see:290 .BR Tomo-Num.floor (3)293 .TP294 .BI Num.hypot\ :\ func(x:\ Num,\ y:\ Num\ ->\ Num)295 Computes the Euclidean norm, $\sqrt{x^2 + y^2}$, of two numbers.297 For more, see:298 .BR Tomo-Num.hypot (3)301 .TP302 .BI Num.is_between\ :\ func(x:\ Num,\ low:\ Num,\ high:\ Num\ ->\ Bool)303 Determines if a number is between two numbers (inclusive).305 For more, see:306 .BR Tomo-Num.is_between (3)309 .TP310 .BI Num.isfinite\ :\ func(n:\ Num\ ->\ Bool)311 Checks if a number is finite.313 For more, see:314 .BR Tomo-Num.isfinite (3)317 .TP318 .BI Num.isinf\ :\ func(n:\ Num\ ->\ Bool)319 Checks if a number is infinite.321 For more, see:322 .BR Tomo-Num.isinf (3)325 .TP326 .BI Num.j0\ :\ func(x:\ Num\ ->\ Num)327 Computes the Bessel function of the first kind of order 0.329 For more, see:330 .BR Tomo-Num.j0 (3)333 .TP334 .BI Num.j1\ :\ func(x:\ Num\ ->\ Num)335 Computes the Bessel function of the first kind of order 1.337 For more, see:338 .BR Tomo-Num.j1 (3)341 .TP342 .BI Num.log\ :\ func(x:\ Num\ ->\ Num)343 Computes the natural logarithm (base $e$) of a number.345 For more, see:346 .BR Tomo-Num.log (3)349 .TP350 .BI Num.log10\ :\ func(x:\ Num\ ->\ Num)351 Computes the base-10 logarithm of a number.353 For more, see:354 .BR Tomo-Num.log10 (3)357 .TP358 .BI Num.log1p\ :\ func(x:\ Num\ ->\ Num)359 Computes $\log(1 + x)$ for a number.361 For more, see:362 .BR Tomo-Num.log1p (3)365 .TP366 .BI Num.log2\ :\ func(x:\ Num\ ->\ Num)367 Computes the base-2 logarithm of a number.369 For more, see:370 .BR Tomo-Num.log2 (3)373 .TP374 .BI Num.logb\ :\ func(x:\ Num\ ->\ Num)375 Computes the binary exponent (base-2 logarithm) of a number.377 For more, see:378 .BR Tomo-Num.logb (3)381 .TP382 .BI Num.mix\ :\ func(amount:\ Num,\ x:\ Num,\ y:\ Num\ ->\ Num)383 Interpolates between two numbers based on a given amount.385 For more, see:386 .BR Tomo-Num.mix (3)389 .TP390 .BI Num.near\ :\ func(x:\ Num,\ y:\ Num,\ ratio:\ Num\ =\ 1e-9,\ min_epsilon:\ Num\ =\ 1e-9\ ->\ Bool)391 Checks if two numbers are approximately equal within specified tolerances. If two numbers are within an absolute difference or the ratio between the two is small enough, they are considered near each other.393 For more, see:394 .BR Tomo-Num.near (3)397 .TP398 .BI Num.nextafter\ :\ func(x:\ Num,\ y:\ Num\ ->\ Num)399 Computes the next representable value after a given number towards a specified direction.401 For more, see:402 .BR Tomo-Num.nextafter (3)405 .TP406 .BI Num.parse\ :\ func(text:\ Text,\ remainder:\ &Text?\ =\ none\ ->\ Num?)407 Converts a text representation of a number into a floating-point number.409 For more, see:410 .BR Tomo-Num.parse (3)413 .TP414 .BI Num.percent\ :\ func(n:\ Num,\ precision:\ Num\ =\ 0.01\ ->\ Text)415 Convert a number into a percentage text with a percent sign.417 For more, see:418 .BR Tomo-Num.percent (3)421 .TP422 .BI Num.rint\ :\ func(x:\ Num\ ->\ Num)423 Rounds a number to the nearest integer, with ties rounded to the nearest even integer.425 For more, see:426 .BR Tomo-Num.rint (3)429 .TP430 .BI Num.round\ :\ func(x:\ Num\ ->\ Num)431 Rounds a number to the nearest whole number integer.433 For more, see:434 .BR Tomo-Num.round (3)437 .TP438 .BI Num.significand\ :\ func(x:\ Num\ ->\ Num)439 Extracts the significand (or mantissa) of a number.441 For more, see:442 .BR Tomo-Num.significand (3)445 .TP446 .BI Num.sin\ :\ func(x:\ Num\ ->\ Num)447 Computes the sine of a number (angle in radians).449 For more, see:450 .BR Tomo-Num.sin (3)453 .TP454 .BI Num.sinh\ :\ func(x:\ Num\ ->\ Num)455 Computes the hyperbolic sine of a number.457 For more, see:458 .BR Tomo-Num.sinh (3)461 .TP462 .BI Num.sqrt\ :\ func(x:\ Num\ ->\ Num)463 Computes the square root of a number.465 For more, see:466 .BR Tomo-Num.sqrt (3)469 .TP470 .BI Num.tan\ :\ func(x:\ Num\ ->\ Num)471 Computes the tangent of a number (angle in radians).473 For more, see:474 .BR Tomo-Num.tan (3)477 .TP478 .BI Num.tanh\ :\ func(x:\ Num\ ->\ Num)479 Computes the hyperbolic tangent of a number.481 For more, see:482 .BR Tomo-Num.tanh (3)485 .TP486 .BI Num.tgamma\ :\ func(x:\ Num\ ->\ Num)487 Computes the gamma function of a number.489 For more, see:490 .BR Tomo-Num.tgamma (3)493 .TP494 .BI Num.trunc\ :\ func(x:\ Num\ ->\ Num)495 Truncates a number to the nearest integer towards zero.497 For more, see:498 .BR Tomo-Num.trunc (3)501 .TP502 .BI Num.with_precision\ :\ func(n:\ Num,\ precision:\ Num\ ->\ Num)503 Round a number to the given precision level (specified as \fB10\fR, \fB.1\fR, \fB.001\fR etc).505 For more, see:506 .BR Tomo-Num.with_precision (3)509 .TP510 .BI Num.y0\ :\ func(x:\ Num\ ->\ Num)511 Computes the Bessel function of the second kind of order 0.513 For more, see:514 .BR Tomo-Num.y0 (3)517 .TP518 .BI Num.y1\ :\ func(x:\ Num\ ->\ Num)519 Computes the Bessel function of the second kind of order 1.521 For more, see:522 .BR Tomo-Num.y1 (3)