https://bugs.documentfoundation.org/show_bug.cgi?id=126601
--- Comment #8 from Takenori Yasuda <[email protected]> --- I may have identified a possible root cause. Root Cause: - LibreOffice internally stores values using integer twip units - Unit conversion is performed via millimeters (mm) - Excessive rounding is applied at multiple stages --- Definitions (Units): - twip = 1/1440 inch = 1/20 point (pt) - pt = 25.4/72 mm Conversion Constants: - in_per_twip = 1/1440 - mm_per_in = 25.4 - pt_per_in = 72 Details: When 200 mm is converted to twips, the calculation proceeds as follows: (200 / mm_per_in) / in_per_twip = (200 / 25.4) * 1440 ~= 11338.58... The result is then rounded to the nearest integer, so 200 mm is stored as 11339 twips. Next, converting 11339 twips back to mm: 11339 * in_per_twip * mm_per_in = 11339 * (1 / 1440) * 25.4 ~= 200.007... This result is rounded to the nearest 0.01 mm, which is why 11339 twips are displayed as 200.01 mm in the UI. --- Notes: 1. Predefined paper sizes (e.g., A4) appear to use internally fixed dimensions, likely bypassing standard conversions: - Actual short side of A4: 210 mm - Displayed in LibreOffice: 210.00 mm - Value via conversion: varies (210.01 mm, 209.90 mm, 209.97 mm, 209.80 mm, etc.) 2. In contrast, user-defined values go through multiple conversions with rounding at each stage. When mm is used as an intermediate, it is rounded to the nearest 0.01 mm before converting to twips. As a result, UI values may differ depending on the selected unit. Example: - When the default unit is set to "Point" under Tools -> Options -> LibreOffice Writer -> General: - A4 (predefined): - Displayed: 595 pt (rounded) - Internally treated as exactly 210 mm - Displayed after changing default unit to "mm": 210.00 mm - User Input: - 210 mm -> 595.2... pt -> rounded to 595 pt - 595 pt -> rounded to 209.90 mm -> rounded to 11900 twips -> 209.902... mm -> rounded to 209.90 mm - Displayed after changing default unit to "mm": 209.90 mm - When the default unit is set to "mm": - User Input: - 210 mm -> rounded to 11906 twips -> 210.008... mm -> rounded to 210.01 mm --- Additional Info: This also affects font sizes and other values: - 10 pt -> 3.527... mm -> rounded to 3.53 mm -> 199.9... twips -> rounded to 200 twips - 200 twips -> 3.527... mm -> rounded to 3.53 mm -> 10.006... pt -> rounded to 10.01 pt -- You are receiving this mail because: You are the assignee for the bug.
