NumericBox unsafe double conversion
Zolnai Tamás
zolnaitamas2000 at gmail.com
Fri Mar 22 03:44:53 PDT 2013
Hi Kendy,
> Yes, I give it a try.
>
> Great, thanks a lot! :-)
Well, I said I'm interested in this cleanup, but just until it is not too
far from my tasks. :)
I used NumericBox to derive from it while implementing LimitBox and I'd
like to allow the user adding values unlimitedly, so the only limit would
be the maximum value of the used type (in this case sal_Int64). (Anyway, I
think such maximum value for a NumericBox is a rare case. Maybe that's why
this bug dont outcrop yet) So I'm interested only in NumericBox, and I
would do my changes only in it with taking care not to change others
behaviour.
Plus, as I see there are not only multiplication in ConvertDoubleValue, but
division too. Replace these simply with integer division will not result
the same. So that make this situation more difficult to solve only with
integer operations and avoid all double aritmetic. So yes, its getting
complicated, too complicated.
Otherwise in ImplNumericGetValue() the problem of overflow/underflow can be
avoid with these lines
sal_Int64 nValue = aStr.toInt64()
if( OUString::valueOf(nValue) != aStr )
{
if( bNegative )
rValue = SAL_MIN_INT64;
else
rValue = SAL_MAX_INT64;
return sal_True;
}
With this the bevavior would be the excepted, because NumericBox and others
were made to return the maximum value (mnMax, GetMax()) when the typed one
is bigger. (mnMin just the same)
So, I try to solve the problem of NumericBox, but MetricBox remain the
same. Maybe an other day or an other man. :)
Best regards,
Tamás
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20130322/fc64c474/attachment.html>
More information about the LibreOffice
mailing list