From efd4638cf9477e918fd895b730e607f4358bfcd3 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Fri, 7 Nov 2014 17:12:55 +0000 Subject: [PATCH] Fix a rounding error git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@78100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/richtext/richtextformatdlg.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp index 9a03da62d9..601f3bdfde 100644 --- a/src/richtext/richtextformatdlg.cpp +++ b/src/richtext/richtextformatdlg.cpp @@ -691,7 +691,9 @@ bool wxRichTextFormattingDialog::ConvertFromString(const wxString& str, int& ret float value = 0.0; wxSscanf(str.c_str(), wxT("%f"), &value); // Convert from cm - ret = (int) ((value * 100.0) /* + 0.5 */); + // Do this in two steps, since using one step causes strange rounding error for VS 2010 at least. + float v = (value * 100.0); + ret = (int) (v); return true; } else if (unit == wxTEXT_ATTR_UNITS_PERCENTAGE) @@ -703,7 +705,8 @@ bool wxRichTextFormattingDialog::ConvertFromString(const wxString& str, int& ret { float value = 0.0; wxSscanf(str.c_str(), wxT("%f"), &value); - ret = (int) ((value * 100.0) /* + 0.5 */); + float v = (value * 100.0); + ret = (int) (v); } else if (unit == wxTEXT_ATTR_UNITS_POINTS) {