I came here from the Attract Mode website. AM is a multiplatform frontend for arcade/console emulators.
Themes in AM are constructed using Squirrel API.
The problem I’m having is that the following function does not produce a correct result:
print( 1080.0 * 0.025 + “\n” )
print( floor( 1080.0 * 0.025 ) + “\n” )
print( floor( 1080.0 / 40.0 ) + “\n” )
result:
27
26
27
expected result:
27
27
27
I went to the root of the problem and I found out that Squirrel do not store floats in a way IEEE-754 standard specifies.
print( format( “%.30f”, 0.025) )
yields:
0.024999998509883881
instead of:
0.02500000037252902984619140625
Could anyone confirm if it’s a widespread issue or problem with Squirrel implementation in Attract Mode.
The issue is described in more detail here: