code / tomo

Lines41.3K C23.7K Markdown9.7K YAML5.0K Tomo2.3K
7 others 763
Python231 Shell230 make212 INI47 Text21 SVG16 Lua6
(40 lines)
1 '\" t
2 .\" Copyright (c) 2025 Bruce Hill
3 .\" All rights reserved.
4 .\"
5 .TH Num.near 3 2025-11-29 "Tomo man-pages"
6 .SH NAME
7 Num.near \- check if two numbers are near each other
8 .SH LIBRARY
9 Tomo Standard Library
10 .SH SYNOPSIS
11 .nf
12 .BI Num.near\ :\ func(x:\ Num,\ y:\ Num,\ ratio:\ Num\ =\ 1e-9,\ min_epsilon:\ Num\ =\ 1e-9\ ->\ Bool)
13 .fi
14 .SH DESCRIPTION
15 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.
18 .SH ARGUMENTS
20 .TS
21 allbox;
22 lb lb lbx lb
23 l l l l.
24 Name Type Description Default
25 x Num The first number. -
26 y Num The second number. -
27 ratio Num The relative tolerance. Default is \fB1e-9\fR. 1e-9
28 min_epsilon Num The absolute tolerance. Default is \fB1e-9\fR. 1e-9
29 .TE
30 .SH RETURN
31 `yes` if `x` and `y` are approximately equal within the specified tolerances, `no` otherwise.
33 .SH EXAMPLES
34 .EX
35 assert (1.0).near(1.000000001) == yes
36 assert (100.0).near(110, ratio=0.1) == yes
37 assert (5.0).near(5.1, min_epsilon=0.1) == yes
38 .EE
39 .SH SEE ALSO
40 .BR Tomo-Num (3)