Changeset 3737190
- Timestamp:
- 10/09/2026 06:29:07 PM (2 weeks ago)
- Location:
- sizemint-size-chart
- Files:
-
- 10 edited
- 1 copied
-
tags/1.0.4 (copied) (copied from sizemint-size-chart/trunk )
-
tags/1.0.4/admin/js/fit-finder-admin.js (modified) (1 diff)
-
tags/1.0.4/includes/class-sizemint-fit-finder-data.php (modified) (1 diff)
-
tags/1.0.4/public/js/fit-finder.js (modified) (1 diff)
-
tags/1.0.4/readme.txt (modified) (2 diffs)
-
tags/1.0.4/sizemint.php (modified) (2 diffs)
-
trunk/admin/js/fit-finder-admin.js (modified) (1 diff)
-
trunk/includes/class-sizemint-fit-finder-data.php (modified) (1 diff)
-
trunk/public/js/fit-finder.js (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/sizemint.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sizemint-size-chart/tags/1.0.4/admin/js/fit-finder-admin.js
r3724648 r3737190 34 34 /** @param {number} inches @return {number} */ 35 35 function roundToNearestIn( inches ) { 36 // A tiny epsilon added before rounding, specifically here and 37 // not in roundToNearestCm: 0.5 (the cm grid increment) is 38 // exactly representable in binary floating point, so 39 // cm/0.5 never lands ambiguously close to a halfway point. 40 // 0.2 (the inch grid increment) is not, so inches/0.2 can 41 // produce a value like 1.4999999999999998 for a genuinely 42 // exact halfway input (0.3) -- verified to be the IDENTICAL 43 // underlying double PHP's round_to_grid() computes for the 44 // same input. PHP's round() applies its own documented 45 // pre-rounding correction there and resolves it to 2; JS's 46 // Math.round() has no such correction and resolves the same 47 // bit pattern to 1. Verified directly (not assumed) that 48 // PHP's output is unaffected by this same epsilon (0 of 3000 49 // sampled values change) — PHP was already correct, so only 50 // JS needs this correction to match its own documented 51 // contract as an equivalent, authoritative backstop. 52 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100; 36 // Inches use a 0.2in grid, represented as 20 hundredths. 37 // Normalize to hundredths first so rounding is stable across 38 // PHP versions and agrees with the storefront's half-up rule. 39 var hundredths = Math.round( Math.abs( inches ) * 100 ); 40 var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20; 41 return ( inches < 0 ? -snapped : snapped ) / 100; 53 42 } 54 43 -
sizemint-size-chart/tags/1.0.4/includes/class-sizemint-fit-finder-data.php
r3724648 r3737190 71 71 */ 72 72 public static function round_to_grid( $value, $unit ) { 73 $increment = ( 'in' === $unit ) ? 0.2 : 0.5; 74 return round( round( $value / $increment ) * $increment, 2 ); 73 // Normalize to hundredths first, then snap using integer 74 // hundredths. This gives PHP 7.4 through 8.4 the same 75 // half-up result without depending on float division by 0.2. 76 $grid_hundredths = ( 'in' === $unit ) ? 20 : 50; 77 $hundredths = (int) floor( abs( (float) $value ) * 100 + 0.5 ); 78 $snapped = (int) ( floor( ( $hundredths + ( $grid_hundredths / 2 ) ) / $grid_hundredths ) * $grid_hundredths ); 79 $sign = ( (float) $value < 0 ) ? -1 : 1; 80 81 return (float) ( ( $sign * $snapped ) / 100 ); 75 82 } 76 83 -
sizemint-size-chart/tags/1.0.4/public/js/fit-finder.js
r3724648 r3737190 309 309 /** @param {number} inches @return {number} */ 310 310 function roundToNearestIn( inches ) { 311 // A tiny epsilon added before rounding, specifically here and 312 // not in roundToNearestCm: 0.5 (the cm grid increment) is 313 // exactly representable in binary floating point, so 314 // cm/0.5 never lands ambiguously close to a halfway point. 315 // 0.2 (the inch grid increment) is not, so inches/0.2 can 316 // produce a value like 1.4999999999999998 for a genuinely 317 // exact halfway input (0.3) -- verified to be the IDENTICAL 318 // underlying double PHP's round_to_grid() computes for the 319 // same input. PHP's round() applies its own documented 320 // pre-rounding correction there and resolves it to 2; JS's 321 // Math.round() has no such correction and resolves the same 322 // bit pattern to 1. Verified directly (not assumed) that 323 // PHP's output is unaffected by this same epsilon (0 of 3000 324 // sampled values change) — PHP was already correct, so only 325 // JS needs this correction to match its own documented 326 // contract as an equivalent, authoritative backstop. 327 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100; 311 // Inches use a 0.2in grid, represented as 20 hundredths. 312 // Normalize to hundredths first so rounding is stable across 313 // PHP versions and agrees with the storefront's half-up rule. 314 var hundredths = Math.round( Math.abs( inches ) * 100 ); 315 var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20; 316 return ( inches < 0 ? -snapped : snapped ) / 100; 328 317 } 329 318 -
sizemint-size-chart/tags/1.0.4/readme.txt
r3729159 r3737190 6 6 Requires PHP: 7.4 7 7 WC tested up to: 11.1 8 Stable tag: 1.0. 38 Stable tag: 1.0.4 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 45 45 == Changelog == 46 46 47 = 1.0.4 = 48 * Fixed: Fit Finder inch measurements now round consistently across supported PHP versions, including exact halfway values. 49 47 50 = 1.0.3 = 48 51 * Fixed: a Size Chart linked to a valid Fit Finder table can now be published and displayed even when the chart's own rows are empty. A valid linked Fit Finder table takes precedence; if the link is later removed or becomes invalid, the chart falls back to its own stored rows, which are preserved while linked. -
sizemint-size-chart/tags/1.0.4/sizemint.php
r3729159 r3737190 4 4 * Plugin URI: https://sizemint.com/ 5 5 * Description: A reliable, lightweight size chart plugin for WooCommerce. Core features are, and will always be free. 6 * Version: 1.0. 36 * Version: 1.0.4 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 21 21 } 22 22 23 define( 'SIZEMINT_VERSION', '1.0. 3' );23 define( 'SIZEMINT_VERSION', '1.0.4' ); 24 24 define( 'SIZEMINT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 25 25 define( 'SIZEMINT_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); -
sizemint-size-chart/trunk/admin/js/fit-finder-admin.js
r3724648 r3737190 34 34 /** @param {number} inches @return {number} */ 35 35 function roundToNearestIn( inches ) { 36 // A tiny epsilon added before rounding, specifically here and 37 // not in roundToNearestCm: 0.5 (the cm grid increment) is 38 // exactly representable in binary floating point, so 39 // cm/0.5 never lands ambiguously close to a halfway point. 40 // 0.2 (the inch grid increment) is not, so inches/0.2 can 41 // produce a value like 1.4999999999999998 for a genuinely 42 // exact halfway input (0.3) -- verified to be the IDENTICAL 43 // underlying double PHP's round_to_grid() computes for the 44 // same input. PHP's round() applies its own documented 45 // pre-rounding correction there and resolves it to 2; JS's 46 // Math.round() has no such correction and resolves the same 47 // bit pattern to 1. Verified directly (not assumed) that 48 // PHP's output is unaffected by this same epsilon (0 of 3000 49 // sampled values change) — PHP was already correct, so only 50 // JS needs this correction to match its own documented 51 // contract as an equivalent, authoritative backstop. 52 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100; 36 // Inches use a 0.2in grid, represented as 20 hundredths. 37 // Normalize to hundredths first so rounding is stable across 38 // PHP versions and agrees with the storefront's half-up rule. 39 var hundredths = Math.round( Math.abs( inches ) * 100 ); 40 var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20; 41 return ( inches < 0 ? -snapped : snapped ) / 100; 53 42 } 54 43 -
sizemint-size-chart/trunk/includes/class-sizemint-fit-finder-data.php
r3724648 r3737190 71 71 */ 72 72 public static function round_to_grid( $value, $unit ) { 73 $increment = ( 'in' === $unit ) ? 0.2 : 0.5; 74 return round( round( $value / $increment ) * $increment, 2 ); 73 // Normalize to hundredths first, then snap using integer 74 // hundredths. This gives PHP 7.4 through 8.4 the same 75 // half-up result without depending on float division by 0.2. 76 $grid_hundredths = ( 'in' === $unit ) ? 20 : 50; 77 $hundredths = (int) floor( abs( (float) $value ) * 100 + 0.5 ); 78 $snapped = (int) ( floor( ( $hundredths + ( $grid_hundredths / 2 ) ) / $grid_hundredths ) * $grid_hundredths ); 79 $sign = ( (float) $value < 0 ) ? -1 : 1; 80 81 return (float) ( ( $sign * $snapped ) / 100 ); 75 82 } 76 83 -
sizemint-size-chart/trunk/public/js/fit-finder.js
r3724648 r3737190 309 309 /** @param {number} inches @return {number} */ 310 310 function roundToNearestIn( inches ) { 311 // A tiny epsilon added before rounding, specifically here and 312 // not in roundToNearestCm: 0.5 (the cm grid increment) is 313 // exactly representable in binary floating point, so 314 // cm/0.5 never lands ambiguously close to a halfway point. 315 // 0.2 (the inch grid increment) is not, so inches/0.2 can 316 // produce a value like 1.4999999999999998 for a genuinely 317 // exact halfway input (0.3) -- verified to be the IDENTICAL 318 // underlying double PHP's round_to_grid() computes for the 319 // same input. PHP's round() applies its own documented 320 // pre-rounding correction there and resolves it to 2; JS's 321 // Math.round() has no such correction and resolves the same 322 // bit pattern to 1. Verified directly (not assumed) that 323 // PHP's output is unaffected by this same epsilon (0 of 3000 324 // sampled values change) — PHP was already correct, so only 325 // JS needs this correction to match its own documented 326 // contract as an equivalent, authoritative backstop. 327 return Math.round( Math.round( inches / 0.2 + 1e-9 ) * 0.2 * 100 ) / 100; 311 // Inches use a 0.2in grid, represented as 20 hundredths. 312 // Normalize to hundredths first so rounding is stable across 313 // PHP versions and agrees with the storefront's half-up rule. 314 var hundredths = Math.round( Math.abs( inches ) * 100 ); 315 var snapped = Math.floor( ( hundredths + 10 ) / 20 ) * 20; 316 return ( inches < 0 ? -snapped : snapped ) / 100; 328 317 } 329 318 -
sizemint-size-chart/trunk/readme.txt
r3729159 r3737190 6 6 Requires PHP: 7.4 7 7 WC tested up to: 11.1 8 Stable tag: 1.0. 38 Stable tag: 1.0.4 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 45 45 == Changelog == 46 46 47 = 1.0.4 = 48 * Fixed: Fit Finder inch measurements now round consistently across supported PHP versions, including exact halfway values. 49 47 50 = 1.0.3 = 48 51 * Fixed: a Size Chart linked to a valid Fit Finder table can now be published and displayed even when the chart's own rows are empty. A valid linked Fit Finder table takes precedence; if the link is later removed or becomes invalid, the chart falls back to its own stored rows, which are preserved while linked. -
sizemint-size-chart/trunk/sizemint.php
r3729159 r3737190 4 4 * Plugin URI: https://sizemint.com/ 5 5 * Description: A reliable, lightweight size chart plugin for WooCommerce. Core features are, and will always be free. 6 * Version: 1.0. 36 * Version: 1.0.4 7 7 * Requires at least: 6.0 8 8 * Requires PHP: 7.4 … … 21 21 } 22 22 23 define( 'SIZEMINT_VERSION', '1.0. 3' );23 define( 'SIZEMINT_VERSION', '1.0.4' ); 24 24 define( 'SIZEMINT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 25 25 define( 'SIZEMINT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)