cond-cmp-numeric-eq.mk (bmake-20201101) | : | cond-cmp-numeric-eq.mk (bmake-20201117) | ||
---|---|---|---|---|
# $NetBSD: cond-cmp-numeric-eq.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $ | # $NetBSD: cond-cmp-numeric-eq.mk,v 1.5 2020/11/08 21:47:59 rillig Exp $ | |||
# | # | |||
# Tests for numeric comparisons with the == operator in .if conditions. | # Tests for numeric comparisons with the == operator in .if conditions. | |||
# This comparison yields the same result, whether numeric or character-based. | # This comparison yields the same result, whether numeric or character-based. | |||
.if 1 == 1 | .if 1 == 1 | |||
.else | .else | |||
. error | . error | |||
.endif | .endif | |||
# This comparison yields the same result, whether numeric or character-based. | # This comparison yields the same result, whether numeric or character-based. | |||
skipping to change at line 52 | skipping to change at line 52 | |||
# As of 2020-08-23, numeric comparison is implemented as parsing both sides | # As of 2020-08-23, numeric comparison is implemented as parsing both sides | |||
# as double, and then performing a normal comparison. The range of double is | # as double, and then performing a normal comparison. The range of double is | |||
# typically 16 or 17 significant digits, therefore these two numbers seem to | # typically 16 or 17 significant digits, therefore these two numbers seem to | |||
# be equal. | # be equal. | |||
.if 1.000000000000000001 == 1.000000000000000002 | .if 1.000000000000000001 == 1.000000000000000002 | |||
.else | .else | |||
. error | . error | |||
.endif | .endif | |||
# Because an IEEE 754 double can only hold integers with a mantissa of 53 | ||||
# bits, these two numbers are considered the same. The 993 is rounded down | ||||
# to the 992. | ||||
.if 9007199254740993 == 9007199254740992 | ||||
.else | ||||
. error | ||||
.endif | ||||
# The 995 is rounded up, the 997 is rounded down. | ||||
.if 9007199254740995 == 9007199254740997 | ||||
.else | ||||
. error Probably a misconfiguration in the floating point environment, \ | ||||
or maybe a machine without IEEE 754 floating point support. | ||||
.endif | ||||
# There is no = operator for numbers. | # There is no = operator for numbers. | |||
.if !(12345 = 12345) | .if !(12345 = 12345) | |||
. error | . error | |||
.else | .else | |||
. error | . error | |||
.endif | .endif | |||
# There is no === operator for numbers either. | # There is no === operator for numbers either. | |||
.if !(12345 === 12345) | .if !(12345 === 12345) | |||
. error | . error | |||
End of changes. 2 change blocks. | ||||
1 lines changed or deleted | 15 lines changed or added |