[RFC] ::rtl::math::doubleToString: NaN/INF

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[RFC] ::rtl::math::doubleToString: NaN/INF

Michael Stahl-5

hi all,

because of a bug in OOo's ODF export i'd like to change the implementation
of ::rtl::math::doubleToString() in sal/rtl/source/math.cxx.

currently the function does not produce the right strings for double
values Not-a-Number and +/- Infinity.

the XMLSchema-2 specification defines specific literals for these, but
currently the ::rtl::math::doubleToString() function produces different
strings, apparently inspired from what the MSFT runtime library does.

this would be a ABI compatible change, but it would change the strings
produced for these double values.
(of course the other direction is easy: parse both variants.)

this would change the value produced by various RTL methods.
- various ::rtl::math::doubleTo* functions.
- various "C" rtl_math_doubleTo* functions.
- most importantly ::rtl::OUString::valueOf(double).

does anybody rely on the current RTL string representation of
Infinity/Not-a-Number?

regards,
 michael

--
"We think in generalities, but we live in detail."
 -- Alfred North Whitehead


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [RFC] ::rtl::math::doubleToString: NaN/INF

Thomas Lange - Oracle

Hi,

>
> hi all,
>
> because of a bug in OOo's ODF export i'd like to change the implementation
> of ::rtl::math::doubleToString() in sal/rtl/source/math.cxx.
>
> currently the function does not produce the right strings for double
> values Not-a-Number and +/- Infinity.
>
> the XMLSchema-2 specification defines specific literals for these, but
> currently the ::rtl::math::doubleToString() function produces different
> strings, apparently inspired from what the MSFT runtime library does.
>
> this would be a ABI compatible change, but it would change the strings
> produced for these double values.
> (of course the other direction is easy: parse both variants.)
>
> this would change the value produced by various RTL methods.
> - various ::rtl::math::doubleTo* functions.
> - various "C" rtl_math_doubleTo* functions.
> - most importantly ::rtl::OUString::valueOf(double).
>
> does anybody rely on the current RTL string representation of
> Infinity/Not-a-Number?

Looking into this it seems OUString does depend on it. Namely
  OUString OUString::valueOf( float f ) and
  OUString OUString::valueOf( double d )
e.g. by calling rtl_ustr_valueOfDouble which in turn calls
rtl_math_doubleToUString.
Also the functions
  float OUString::toFloat() and
  double OUString::toDouble()
need to match the above ones.

Also keep in mind that Java does define what nan and inf gets converted
to as String
http://www.ifs.tuwien.ac.at/ifs/lehre/eprog/javadoc/jdk/docs/api/java/lang/Double.html#toString%28double%29
and from string
http://www.ifs.tuwien.ac.at/ifs/lehre/eprog/javadoc/jdk/docs/api/java/lang/Double.html#valueOf%28java.lang.String%29
I don't know though if the Java bridge or whatever takes care of this
task or not when OUStrings are involved in the Uno API.


Thomas



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [RFC] ::rtl::math::doubleToString: NaN/INF

Michael Stahl-5
In reply to this post by Michael Stahl-5
On 24/08/2010 16:48, Michael Stahl wrote:
> this would change the value produced by various RTL methods.
> - various ::rtl::math::doubleTo* functions.
> - various "C" rtl_math_doubleTo* functions.
> - most importantly ::rtl::OUString::valueOf(double).
>
> does anybody rely on the current RTL string representation of
> Infinity/Not-a-Number?

nobody complained, so the change is now integrated in OOO330:
http://hg.services.openoffice.org/re/OOO330_next?cmd=changeset;node=5dc8dc01f4d7

> regards,
>  michael

--
"I like verbing words.  Verbing weirds language." -- Calvin, to Hobbes


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]