Skip to content

longdouble problem #3478

@yzewei

Description

@yzewei

Running NumPy on LA64/Box64, test_arrayprint.py::TestComplexArray::test_str fails with the error ValueError: not enough values ​​to unpack (expected 2, got 1). The error message indicates that inf or nan values ​​in np.clongdouble are misinterpreted as finite values, causing the failure.

Could the following approach be used?
Provide x86_80bit-directed parsing for the long double determination function in Box64, independent of the host libm:
Implement, for example, box64_x86_isnanl / isinf / isfinite / fpclassify / signbit
parse 80-bit formats (sign/exp/mantissa) to determine inf/nan/zero/subnormal
point the *l version to these helpers in wrappedlibm_private.
only for the classification logic of x86 long double, minimizing the impact.

Currently, attempts to use methods such as BOX64_X87_NO80BITS=1 are still failing with errors.

import numpy as np

x = np.longdouble('inf')
print("isfinite(ld inf) =", np.isfinite(x))
print("isinf(ld inf)    =", np.isinf(x))

z = np.array([np.longdouble('inf') + 1j], dtype=np.clongdouble)
print("isfinite(cld inf) =", np.isfinite(z))

[root@oe-15 abi2-build]# BOX64_X87_NO80BITS=1 ./box64 python3 test.py 
[BOX64] Box64 loongarch64 v0.4.1 07e82e62 with Dynarec built on Feb  9 2026 01:11:55
[BOX64] Dynarec for LoongArch with extension LSX LASX LBT_X86 LAM_BH LAMCAS SCQ FRECIP
[BOX64] Running on Loongson-3C6000/D with 128 cores, pagesize: 16384
[BOX64] Will use hardware counter measured at 2.1 GHz
[BOX64] Detected 48bits at least of address space
[BOX64] Warning, older then 2.34 pthread_kill not found, using current one
[BOX64] Counted 36 Env var
[BOX64] Library search path: 
[BOX64] Binary search path: ./:bin/:/home/yzw/python-trans/python-standalone/bin/:/usr/local/sbin/:/usr/local/bin/:/usr/sbin/:/usr/bin/:/root/bin/
[BOX64] Looking for python3
[BOX64] argv[1]="test.py"
[BOX64] Rename process to "python3.11d"
[BOX64] Using native(wrapped) libpthread.so.0
[BOX64] Using native(wrapped) libdl.so.2
[BOX64] Using native(wrapped) libutil.so.1
[BOX64] Using native(wrapped) librt.so.1
[BOX64] Using native(wrapped) libm.so.6
[BOX64] Using native(wrapped) libc.so.6
[BOX64] Using native(wrapped) ld-linux-x86-64.so.2
[BOX64] Using native(wrapped) libbsd.so.0
[BOX64] Using emulated /home/yzw/python-trans/python-standalone/lib/python3.11/site-packages/numpy/_core/_multiarray_umath.cpython-311d-x86_64-linux-gnu.so
[BOX64] Using emulated /usr/lib/box64-x86_64-linux-gnu/libstdc++.so.6
[BOX64] Using emulated /usr/lib/box64-x86_64-linux-gnu/libgcc_s.so.1
[BOX64] Using emulated /home/yzw/python-trans/python-standalone/lib/python3.11/site-packages/numpy/linalg/_umath_linalg.cpython-311d-x86_64-linux-gnu.so
isfinite(ld inf) = False
isinf(ld inf)    = False
isfinite(cld inf) = [False]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions