diff --git a/include/wx/richtext/richtextxml.h b/include/wx/richtext/richtextxml.h index 6f25e367ea..979fa09e88 100644 --- a/include/wx/richtext/richtextxml.h +++ b/include/wx/richtext/richtextxml.h @@ -51,7 +51,7 @@ public: static wxString MakeString(const int& v) { return wxString::Format(wxT("%d"), v); } static wxString MakeString(const long& v) { return wxString::Format(wxT("%ld"), v); } - static wxString MakeString(const double& v) { return wxString::Format(wxT("%.2f"), (float) v); } + static wxString MakeString(const double& v) { return wxString::Format(wxS("%.2f"), v); } static wxString MakeString(const wxString& s) { return s; } static wxString MakeString(const wxColour& col) { return wxT("#") + ColourToHexString(col); } @@ -101,7 +101,7 @@ public: static void AddString(wxString& str, const int& v) { str << wxString::Format(wxT("%d"), v); } static void AddString(wxString& str, const long& v) { str << wxString::Format(wxT("%ld"), v); } - static void AddString(wxString& str, const double& v) { str << wxString::Format(wxT("%.2f"), (float) v); } + static void AddString(wxString& str, const double& v) { str << wxString::Format(wxS("%.2f"), v); } static void AddString(wxString& str, const wxChar* s) { str << s; } static void AddString(wxString& str, const wxString& s) { str << s; } static void AddString(wxString& str, const wxColour& col) { str << wxT("#") << ColourToHexString(col); } diff --git a/include/wx/string.h b/include/wx/string.h index 2824b280bf..f6bc9e1377 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -2027,7 +2027,7 @@ public: #endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG // insert a float into string wxString& operator<<(float f) - { return (*this) << Format(wxT("%f"), f); } + { return *this << static_cast(f); } // insert a double into string wxString& operator<<(double d) { return (*this) << Format(wxT("%g"), d); } diff --git a/samples/typetest/typetest.cpp b/samples/typetest/typetest.cpp index 891a23b568..cbca91b202 100644 --- a/samples/typetest/typetest.cpp +++ b/samples/typetest/typetest.cpp @@ -146,8 +146,8 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event)) text_output << d << "\n"; std_file_output << d << "\n"; - float f = (float)0.00001; - tmp.Printf( "Float: %f\n", f ); + float f = 0.00001f; + tmp.Printf( "Float: %f\n", double(f) ); textCtrl.WriteText( tmp ); text_output << f << "\n"; std_file_output << f << "\n"; @@ -177,7 +177,7 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event)) textCtrl.WriteText( tmp ); std_file_input >> f; - tmp.Printf( "Float: %f\n", f ); + tmp.Printf( "Float: %f\n", double(f) ); textCtrl.WriteText( tmp ); char std_buf[200]; @@ -207,7 +207,7 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event)) textCtrl.WriteText( tmp ); text_input >> f; - tmp.Printf( "Float: %f\n", f ); + tmp.Printf( "Float: %f\n", double(f) ); textCtrl.WriteText( tmp ); text_input >> str; diff --git a/samples/validate/validate.cpp b/samples/validate/validate.cpp index 40397aa270..be571eda8b 100644 --- a/samples/validate/validate.cpp +++ b/samples/validate/validate.cpp @@ -224,7 +224,7 @@ void MyFrame::OnTestDialog(wxCommandEvent& WXUNUSED(event)) m_listbox->Append(wxString::Format("integer value: %d", g_data.m_intValue)); m_listbox->Append(wxString::Format("small int value: %u", g_data.m_smallIntValue)); m_listbox->Append(wxString::Format("double value: %.3f", g_data.m_doubleValue)); - m_listbox->Append(wxString::Format("percent value: %.4f", g_data.m_percentValue)); + m_listbox->Append(wxString::Format("percent value: %.4f", double(g_data.m_percentValue))); } } diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp index cd1d678ebe..2dcb7e5874 100644 --- a/src/common/dcsvg.cpp +++ b/src/common/dcsvg.cpp @@ -141,7 +141,7 @@ wxString GetPenPattern(const wxPen& pen) // When the pen width increases, lines become thicker and unrecognizable. // Multiplying with 1/3th of the width creates line styles matching the appearance of wxDC. // The pen width is not used to modify user provided dash styles. - float w = pen.GetWidth(); + double w = pen.GetWidth(); if (pen.GetWidth() == 0) w = 1; w = w / 3; diff --git a/src/common/valgen.cpp b/src/common/valgen.cpp index 9dabec178d..7c5790b107 100644 --- a/src/common/valgen.cpp +++ b/src/common/valgen.cpp @@ -349,7 +349,7 @@ bool wxGenericValidator::TransferToWindow() } else if (m_pFloat) { - pControl->SetValue(wxString::Format(wxT("%g"), *m_pFloat)); + pControl->SetValue(wxString::Format(wxS("%g"), double(*m_pFloat))); return true; } else if (m_pDouble) diff --git a/src/msw/debughlp.cpp b/src/msw/debughlp.cpp index 479919c397..ac344ed66b 100644 --- a/src/msw/debughlp.cpp +++ b/src/msw/debughlp.cpp @@ -315,7 +315,7 @@ wxDbgHelpDLL::DumpBaseType(BasicType bt, DWORD64 length, PVOID pAddress) if ( bt == BASICTYPE_FLOAT ) { - s.Printf(wxT("%f"), *(PFLOAT)pAddress); + s.Printf(wxS("%f"), double(*(PFLOAT)pAddress)); handled = true; } diff --git a/src/richtext/richtextformatdlg.cpp b/src/richtext/richtextformatdlg.cpp index 6d1e571cef..032099b73b 100644 --- a/src/richtext/richtextformatdlg.cpp +++ b/src/richtext/richtextformatdlg.cpp @@ -615,7 +615,7 @@ void wxRichTextFormattingDialog::SetDimensionValue(wxTextAttrDimension& dim, wxT else if (dim.GetUnits() == wxTEXT_ATTR_UNITS_TENTHS_MM) { unitsIdx = 1; // By default, the 2nd in the list. - float value = dim.GetValue() / 100.0f; + double value = dim.GetValue() / 100.0; valueCtrl->SetValue(wxString::Format(wxT("%.2f"), value)); } else if (dim.GetUnits() == wxTEXT_ATTR_UNITS_PERCENTAGE) @@ -626,7 +626,7 @@ void wxRichTextFormattingDialog::SetDimensionValue(wxTextAttrDimension& dim, wxT else if (dim.GetUnits() == wxTEXT_ATTR_UNITS_HUNDREDTHS_POINT) { unitsIdx = 3; // By default, the 4th in the list. - float value = dim.GetValue() / 100.0f; + double value = dim.GetValue() / 100.0; valueCtrl->SetValue(wxString::Format(wxT("%.2f"), value)); } else if (dim.GetUnits() == wxTEXT_ATTR_UNITS_POINTS) diff --git a/src/richtext/richtexthtml.cpp b/src/richtext/richtexthtml.cpp index 56261546e7..58f10d6e24 100644 --- a/src/richtext/richtexthtml.cpp +++ b/src/richtext/richtexthtml.cpp @@ -325,29 +325,29 @@ void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxRichTextAttr& WXUNU if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && thisStyle.HasParagraphSpacingBefore()) { - float spacingBeforeMM = thisStyle.GetParagraphSpacingBefore() / 10.0f; + double spacingBeforeMM = thisStyle.GetParagraphSpacingBefore() / 10.0; styleStr += wxString::Format(wxT("margin-top: %.2fmm; "), spacingBeforeMM); } if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && thisStyle.HasParagraphSpacingAfter()) { - float spacingAfterMM = thisStyle.GetParagraphSpacingAfter() / 10.0f; + double spacingAfterMM = thisStyle.GetParagraphSpacingAfter() / 10.0; styleStr += wxString::Format(wxT("margin-bottom: %.2fmm; "), spacingAfterMM); } - float indentLeftMM = (thisStyle.GetLeftIndent() + thisStyle.GetLeftSubIndent())/10.0f; + double indentLeftMM = (thisStyle.GetLeftIndent() + thisStyle.GetLeftSubIndent()) / 10.0; if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && (indentLeftMM > 0.0)) { styleStr += wxString::Format(wxT("margin-left: %.2fmm; "), indentLeftMM); } - float indentRightMM = thisStyle.GetRightIndent()/10.0f; + double indentRightMM = thisStyle.GetRightIndent() / 10.0; if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && thisStyle.HasRightIndent() && (indentRightMM > 0.0)) { styleStr += wxString::Format(wxT("margin-right: %.2fmm; "), indentRightMM); } // First line indentation - float firstLineIndentMM = - thisStyle.GetLeftSubIndent() / 10.0f; + double firstLineIndentMM = - thisStyle.GetLeftSubIndent() / 10.0; if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && (firstLineIndentMM > 0.0)) { styleStr += wxString::Format(wxT("text-indent: %.2fmm; "), firstLineIndentMM); @@ -385,13 +385,13 @@ void wxRichTextHTMLHandler::BeginParagraphFormatting(const wxRichTextAttr& WXUNU if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && thisStyle.HasParagraphSpacingBefore()) { - float spacingBeforeMM = thisStyle.GetParagraphSpacingBefore() / 10.0f; + double spacingBeforeMM = thisStyle.GetParagraphSpacingBefore() / 10.0; styleStr += wxString::Format(wxT("margin-top: %.2fmm; "), spacingBeforeMM); } if ((GetFlags() & wxRICHTEXT_HANDLER_USE_CSS) && thisStyle.HasParagraphSpacingAfter()) { - float spacingAfterMM = thisStyle.GetParagraphSpacingAfter() / 10.0f; + double spacingAfterMM = thisStyle.GetParagraphSpacingAfter() / 10.0; styleStr += wxString::Format(wxT("margin-bottom: %.2fmm; "), spacingAfterMM); } diff --git a/src/richtext/richtextxml.cpp b/src/richtext/richtextxml.cpp index c05e13790c..4804a10e4f 100644 --- a/src/richtext/richtextxml.cpp +++ b/src/richtext/richtextxml.cpp @@ -2033,7 +2033,7 @@ void wxRichTextXMLHelper::AddAttribute(wxString& str, const wxString& name, cons void wxRichTextXMLHelper::AddAttribute(wxString& str, const wxString& name, const double& v) { - str << wxT(" ") << name << wxT("=\"") << wxString::Format(wxT("%.2f"), (float) v) << wxT("\""); + str << wxS(" ") << name << wxS("=\"") << wxString::Format(wxS("%.2f"), v) << wxS("\""); } void wxRichTextXMLHelper::AddAttribute(wxString& str, const wxString& name, const wxChar* s)