blob: 234b36a52f729898bd6eaf11b4c92ae05fd28704 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH Num.near 3 2025-09-06 "Tomo man-pages"
.SH NAME
Num.near \- check if two numbers are near each other
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI Num.near\ :\ func(x:\ Num,\ y:\ Num,\ ratio:\ Num\ =\ 1e-9,\ min_epsilon:\ Num\ =\ 1e-9\ ->\ Bool)
.fi
.SH DESCRIPTION
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.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
x Num The first number. -
y Num The second number. -
ratio Num The relative tolerance. Default is `1e-9`. 1e-9
min_epsilon Num The absolute tolerance. Default is `1e-9`. 1e-9
.TE
.SH RETURN
`yes` if `x` and `y` are approximately equal within the specified tolerances, `no` otherwise.
.SH EXAMPLES
.EX
>> (1.0).near(1.000000001)
= yes
>> (100.0).near(110, ratio=0.1)
= yes
>> (5.0).near(5.1, min_epsilon=0.1)
= yes
.EE
|