Bug 126601 - EDITING: Page Settings 130 x 200mm are imprecisely saved as 130 x 200,01mm
Summary: EDITING: Page Settings 130 x 200mm are imprecisely saved as 130 x 200,01mm
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: lowest normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Page
  Show dependency treegraph
 
Reported: 2019-07-29 13:54 UTC by canned
Modified: 2025-06-07 10:33 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description canned 2019-07-29 13:54:23 UTC
Page Settings 130 x 200mm are imprecisely saved as 130 x 200,01mm.

How to reproduce:
- Open new document (A4 -> 210 x 297mm)
- Format > Page: Change page format to 130 x 200mm + Click OK
- Check Format > Page: Page Height is imprecisely saved as 200,01mm

Same issue with Insert > Form > Standard > Rectangle
- Draw Rectangle
- Select Rectangle + Right click "Position and size"
- Manually type size width 50mm and size height 50mm and Click OK
- Select Rectangle + Right click "Position and size"
- Size width is imprecisely saved as 50,01mm and size height as 50,01mm

Version: 6.2.5.2 (x64)
Build-ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU-Threads: 4; BS: Windows 6.1; UI-Render: Standard; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc: threaded
Comment 1 Dieter 2019-07-30 03:54:21 UTC
Not reproducible for me with

Version: 6.2.5.2 (x64)
Build-ID: 1ec314fa52f458adc18c4f025c545a4e8b22c159
CPU-Threads: 4; BS: Windows 10.0; UI-Render: GL; VCL: win; 
Gebietsschema: de-DE (de_DE); UI-Sprache: de-DE
Calc: threaded
Comment 2 Xisco Faulí 2019-09-03 08:20:25 UTC
Thank you for reporting the bug.
it seems you're using an old version of LibreOffice.
Could you please try to reproduce it with the latest version of LibreOffice
from https://www.libreoffice.org/download/libreoffice-fresh/ ?
I have set the bug's status to 'NEEDINFO'. Please change it back to
'UNCONFIRMED' if the bug is still present in the latest version.
Comment 3 Thorsten Behrens (allotropia) 2019-11-04 13:50:52 UTC
Confirm with 6.2.7 (you need to set measurement units to millimeter to see that .01 millimeter difference).
Comment 4 Xisco Faulí 2019-11-05 10:43:32 UTC
Also reproduced in

Version 4.1.0.0.alpha0+ (Build ID: ff140bb6b8b109f14c270ff059f0b8d71dab5d6)
Comment 5 Justin L 2021-10-06 13:22:43 UTC
I reproduce in LO 3.5 in bibisect-43all, so I assume inherited from OOo.

FYI using 199.999 also rounds up to 200.01. So I see the reported issue, but I don't know why it matters...  (Knowing why it matters would be very helpful.)
Comment 6 QA Administrators 2025-05-20 03:10:39 UTC Comment hidden (obsolete)
Comment 7 Takenori Yasuda 2025-05-20 05:40:15 UTC
Still reproduced.

Version: 25.2.3.2 (X86_64) / LibreOffice Community
Build ID: bbb074479178df812d175f709636b368952c2ce3
CPU threads: 8; OS: Windows 11 X86_64 (10.0 build 26100); UI render: Skia/Raster; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: CL threaded Jumbo

Version: 25.8.0.0.alpha1+ (X86_64) / LibreOffice Community
Build ID: 6190fe56f72008e0b6d0e502bf94099e72b9d202
CPU threads: 8; OS: Windows 11 X86_64 (build 26100); UI render: default; VCL: win
Locale: ja-JP (ja_JP); UI: ja-JP
Calc: threaded


Could it be an issue with floating-point number processing, rounding, or unit conversion? I've seen similar things occurred in other places where length is entered.
Comment 8 Takenori Yasuda 2025-06-07 10:33:30 UTC
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