apple / swift-numerics

Advanced mathematical types and functions for Swift

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

testIntegerExponentDoubleAndSmaller() from RealTests.IntegerExponentTests/testDouble fails on 32-bit platforms

finagolfin opened this issue · comments

I've recently put out a Swift toolchain that runs on 32-bit Android ARMv7 devices, termux/termux-packages#5843, and have been testing some Swift packages with it to make sure it works okay. The good news is that all other tests pass when built for 32-bit ARMv7, but all 10 asserts in this test function fail. The problem appears to be that Int32.max isn't large enough to saturate the output when exponentiating, as it would be for Int64.max.

I checked by compiling this equivalent C file to the first assert for Android AArch64/ARMv7 and linux x86_64/i686:

#include <math.h>
#include <stdio.h>

int main(){
    double y = 2147483646;
    double d = nextafter(1.0, INFINITY);
    double x = -d;
    printf("base is %a and exponent is %a\n", x, y);
    double z = pow(x, y);
    printf("got %a\n", z);
}

All four platforms gave me the same result:

> clang -target armv7-linux-android check.c -lm -o check
> ./check
base is -0x1.0000000000001p+0 and exponent is 0x1.fffffff8p+30
got 0x1.00000800001fep+0

I'm guessing these tests aren't being run on 32-bit platforms anymore, reporting my results.

@buttaface this should be resolved on main; please let me know if you have further trouble.

Yep, just built and ran the tests for ARMv7, no failures now.