{"record":{"id":"431171ed43678679","repo":"PHPOffice/PhpSpreadsheet","slug":"required-floating-point-format-not-supported-on-th","errorCode":null,"errorMessage":"Required floating point format not supported on this platform.","messagePattern":"Required floating point format not supported on this platform\\.","errorType":"exception","errorClass":"PhpOffice\\PhpSpreadsheet\\Writer\\Exception","httpStatus":null,"severity":"error","filePath":"src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php","lineNumber":89,"sourceCode":"    }\n\n    /**\n     * Determine the byte order and store it as class data to avoid\n     * recalculating it for each call to new().\n     */\n    public static function getByteOrder(): int\n    {\n        if (!isset(self::$byteOrder)) {\n            // Check if \"pack\" gives the required IEEE 64bit float\n            $teststr = pack('d', 1.2345);\n            $number = pack('C8', 0x8D, 0x97, 0x6E, 0x12, 0x83, 0xC0, 0xF3, 0x3F);\n            if ($number == $teststr) {\n                $byte_order = 0; // Little Endian\n            } elseif ($number == strrev($teststr)) {\n                $byte_order = 1; // Big Endian\n            } else {\n                // Give up. I'll fix this in a later version.\n                throw new WriterException('Required floating point format not supported on this platform.');\n            }\n            self::$byteOrder = $byte_order;\n        }\n\n        return self::$byteOrder;\n    }\n\n    /**\n     * General storage function.\n     *\n     * @param string $data binary data to append\n     */\n    protected function append(string $data): void\n    {\n        if (strlen($data) - 4 > $this->limit) {\n            $data = $this->addContinue($data);\n        }\n        $this->_data .= $data;","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/PHPOffice/PhpSpreadsheet/blob/65b080eef4d9fd11a5796135ab145883e5c3d6a6/src/PhpSpreadsheet/Writer/Xls/BIFFwriter.php#L71-L107","documentation":"The BIFF8/Xls format stores numbers as IEEE 754 64-bit doubles, and BIFFwriter::getByteOrder() self-tests this by packing 1.2345 and comparing the bytes against the known little- and big-endian encodings. If neither matches, PHP on this platform does not produce IEEE 754 doubles with pack('d', ...) and every numeric cell would be serialized corruptly, so the writer refuses to continue. On any mainstream platform (x86, x86-64, ARM, most PowerPC configurations) this check never fails.","triggerScenarios":"Running the Xls writer on exotic hardware or a patched PHP whose 'd' conversion produces a non-IEEE-754 or unusual mixed-endian byte layout. Effectively unreachable on stock PHP builds for common architectures.","commonSituations":"Practically never seen in the wild; occasionally reported after custom/patched PHP builds or emulated environments with broken float handling. If you see it, suspect the PHP binary, not your spreadsheet.","solutions":["Switch to a writer without the BIFF dependency - Xlsx or CSV - on that platform.","Verify PHP float handling: var_dump(bin2hex(pack('d', 1.2345))) should be a clean little- or big-endian IEEE 754 pattern; if not, rebuild/replace the PHP build.","Do not attempt to work around it in the spreadsheet data - the check is platform-wide."],"exampleFix":"// before\n(new \\PhpOffice\\PhpSpreadsheet\\Writer\\Xls($spreadsheet))->save('out.xls');\n// throws: Required floating point format not supported on this platform.\n\n// after\ntry {\n    (new \\PhpOffice\\PhpSpreadsheet\\Writer\\Xls($spreadsheet))->save('out.xls');\n} catch (\\PhpOffice\\PhpSpreadsheet\\Writer\\Exception $e) {\n    // IEEE 754 doubles unavailable on this platform: fall back\n    (new \\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx($spreadsheet))->save('out.xlsx');\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    (new \\PhpOffice\\PhpSpreadsheet\\Writer\\Xls($spreadsheet))->save($path);\n} catch (\\PhpOffice\\PhpSpreadsheet\\Writer\\Exception $e) {\n    if (str_contains($e->getMessage(), 'floating point format')) {\n        // platform cannot produce IEEE 754 doubles via pack('d') - use a non-BIFF format\n        (new \\PhpOffice\\PhpSpreadsheet\\Writer\\Xlsx($spreadsheet))->save(preg_replace('/\\.xls$/', '.xlsx', $path));\n    } else {\n        throw $e;\n    }\n}","preventionTips":["Smoke-test exotic deployment targets once with a tiny Xls export during provisioning.","Treat this error as a platform/build defect (check bin2hex(pack('d', 1.2345))), never as a data issue.","Offer Xlsx/CSV as configurable fallback formats in export pipelines that may run on heterogeneous hardware."],"tags":["xls","biff8","platform","endian","ieee754","pack"],"backgroundTag":"unsupported-float-representation","analyzedSha":"65b080eef4d9fd11a5796135ab145883e5c3d6a6","analyzedAt":"2026-08-17T05:40:41.646Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}