cond-cmp-numeric-eq.mk revision 1.1
11.1Srillig# $NetBSD: cond-cmp-numeric-eq.mk,v 1.1 2020/08/23 13:50:17 rillig Exp $
21.1Srillig#
31.1Srillig# Tests for numeric comparisons with the == operator in .if conditions.
41.1Srillig
51.1Srillig# This comparison yields the same result, whether numeric or character-based.
61.1Srillig.if 1 == 1
71.1Srillig.else
81.1Srillig.error
91.1Srillig.endif
101.1Srillig
111.1Srillig# This comparison yields the same result, whether numeric or character-based.
121.1Srillig.if 1 == 2
131.1Srillig.error
141.1Srillig.endif
151.1Srillig
161.1Srillig.if 2 == 1
171.1Srillig.error
181.1Srillig.endif
191.1Srillig
201.1Srillig# Scientific notation is supported, as per strtod.
211.1Srillig.if 2e7 == 2000e4
221.1Srillig.else
231.1Srillig.error
241.1Srillig.endif
251.1Srillig
261.1Srillig.if 2000e4 == 2e7
271.1Srillig.else
281.1Srillig.error
291.1Srillig.endif
301.1Srillig
311.1Srillig# Trailing zeroes after the decimal point are irrelevant for the numeric
321.1Srillig# value.
331.1Srillig.if 3.30000 == 3.3
341.1Srillig.else
351.1Srillig.error
361.1Srillig.endif
371.1Srillig
381.1Srillig.if 3.3 == 3.30000
391.1Srillig.else
401.1Srillig.error
411.1Srillig.endif
421.1Srillig
431.1Srillig# As of 2020-08-23, numeric comparison is implemented as parsing both sides
441.1Srillig# as double, and then performing a normal comparison.  The range of double is
451.1Srillig# typically 16 or 17 significant digits, therefore these two numbers seem to
461.1Srillig# be equal.
471.1Srillig.if 1.000000000000000001 == 1.000000000000000002
481.1Srillig.else
491.1Srillig.error
501.1Srillig.endif
511.1Srillig
521.1Srilligall:
531.1Srillig	@:;
54