mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Allow fixed-point constants to have unsigned range (#1084)
For example with Q.4, $F0 is 15.0, which no longer warns
This commit is contained in:
@@ -1179,7 +1179,7 @@ static uint32_t readFractionalPart(uint32_t integer)
|
||||
precision = fixPrecision;
|
||||
}
|
||||
|
||||
if (integer >= ((uint32_t)1 << (precision - 1)))
|
||||
if (integer >= ((uint64_t)1 << precision))
|
||||
warning(WARNING_LARGE_CONSTANT, "Magnitude of fixed-point constant is too large\n");
|
||||
|
||||
// Cast to unsigned avoids undefined overflow behavior
|
||||
|
||||
13
test/asm/fixed-point-magnitude.asm
Normal file
13
test/asm/fixed-point-magnitude.asm
Normal file
@@ -0,0 +1,13 @@
|
||||
OPT Q.4
|
||||
println 1.0
|
||||
println -1.0
|
||||
println 0.0625
|
||||
println -0.0625
|
||||
println 7.25
|
||||
println -7.25
|
||||
println 12.25
|
||||
println -12.25
|
||||
println 15.9375
|
||||
println -15.9375
|
||||
println 20.0
|
||||
println -20.0
|
||||
4
test/asm/fixed-point-magnitude.err
Normal file
4
test/asm/fixed-point-magnitude.err
Normal file
@@ -0,0 +1,4 @@
|
||||
warning: fixed-point-magnitude.asm(12): [-Wlarge-constant]
|
||||
Magnitude of fixed-point constant is too large
|
||||
warning: fixed-point-magnitude.asm(13): [-Wlarge-constant]
|
||||
Magnitude of fixed-point constant is too large
|
||||
12
test/asm/fixed-point-magnitude.out
Normal file
12
test/asm/fixed-point-magnitude.out
Normal file
@@ -0,0 +1,12 @@
|
||||
$10
|
||||
$FFFFFFF0
|
||||
$1
|
||||
$FFFFFFFF
|
||||
$74
|
||||
$FFFFFF8C
|
||||
$C4
|
||||
$FFFFFF3C
|
||||
$FF
|
||||
$FFFFFF01
|
||||
$140
|
||||
$FFFFFEC0
|
||||
@@ -1,5 +1,3 @@
|
||||
warning: opt-Q.asm(10) -> opt-Q.asm::REPT~1(12) -> opt-Q.asm::test(5): [-Wlarge-constant]
|
||||
Magnitude of fixed-point constant is too large
|
||||
error: opt-Q.asm(17) -> opt-Q.asm::test(3):
|
||||
Argument for option 'Q' must be between 1 and 31
|
||||
error: opt-Q.asm(18) -> opt-Q.asm::test(3):
|
||||
|
||||
Reference in New Issue
Block a user