[php-src] PR #12333: number_format: float within range of int can be cast to int …

From: Date: Sat, 30 Sep 2023 15:18:58 +0000
Subject: [php-src] PR #12333: number_format: float within range of int can be cast to int …
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-23753@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/12333 Author: marc-mabe …before rounding of numbers above 2^53 to not loose precision. On casting float to int fractional digits gets truncated but as far as I'm aware of double numbers above 2^53 can't store fractions anymore. This is the diff of the added test numbers without this change: ``` -- --- testing: float(9.223372036854775E+18) ... with precision 5: string(31) "9,223,372,036,854,774,784.00000" ... with precision 0: string(25) "9,223,372,036,854,774,784" 169- ... with precision -1: string(25) "9,223,372,036,854,774,780" 170- ... with precision -5: string(25) "9,223,372,036,854,800,000" 169+ ... with precision -1: string(25) "9,223,372,036,854,774,784" 170+ ... with precision -5: string(25) "9,223,372,036,854,800,384" ... with precision -10: string(25) "9,223,372,040,000,000,000" ... with precision -11: string(25) "9,223,372,000,000,000,000" ... with precision -17: string(25) "9,200,000,000,000,000,000" -- --- testing: float(-9.223372036854775E+18) ... with precision 5: string(32) "-9,223,372,036,854,774,784.00000" ... with precision 0: string(26) "-9,223,372,036,854,774,784" 180- ... with precision -1: string(26) "-9,223,372,036,854,774,780" 181- ... with precision -5: string(26) "-9,223,372,036,854,800,000" 180+ ... with precision -1: string(26) "-9,223,372,036,854,774,784" 181+ ... with precision -5: string(26) "-9,223,372,036,854,800,384" ... with precision -10: string(26) "-9,223,372,040,000,000,000" ... with precision -11: string(26) "-9,223,372,000,000,000,000" ... with precision -17: string(26) "-9,200,000,000,000,000,000" -- ```

« previous php.git-pulls (#23753) next »