1# $NetBSD: cond-cmp-numeric-ge.mk,v 1.3 2023/09/07 05:36:33 rillig Exp $
2#
3# Tests for numeric comparisons with the >= operator in .if conditions.
4
5# When both sides are equal, the >= operator always yields true.
6.if 1 >= 1
7.else
8.  error
9.endif
10
11# This comparison yields the same result, whether numeric or character-based.
12.if 1 >= 2
13.  error
14.endif
15
16.if 2 >= 1
17.else
18.  error
19.endif
20
21# If this comparison were character-based instead of numerical, the
22# 5 would be >= 14 since its first digit is greater.
23.if 5 >= 14
24.  error
25.endif
26
27.if 14 >= 5
28.else
29.  error
30.endif
31
32# Scientific notation is supported, as per strtod.
33.if 2e7 >= 1e8
34.  error
35.endif
36
37.if 1e8 >= 2e7
38.else
39.  error
40.endif
41
42# Floating pointer numbers can be compared as well.
43# This might be tempting to use for version numbers, but there are a few pitfalls.
44.if 3.141 >= 111.222
45.  error
46.endif
47
48.if 111.222 >= 3.141
49.else
50.  error
51.endif
52
53# When parsed as a version number, 3.30 is greater than 3.7.
54# Since make parses numbers as plain numbers, that leads to wrong results.
55# Numeric comparisons are not suited for comparing version number.
56.if 3.30 >= 3.7
57.  error
58.endif
59
60.if 3.7 >= 3.30
61.else
62.  error
63.endif
64
65# Numeric comparison works by parsing both sides
66# as double, and then performing a normal comparison.  The range of double is
67# typically 16 or 17 significant digits, therefore these two numbers seem to
68# be equal.
69.if 1.000000000000000001 >= 1.000000000000000002
70.else
71.  error
72.endif
73
74all:
75	@:;
76