Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi Tamás,

Zolnai Tamás píše v Pá 15. 03. 2013 v 13:39 +0100:

  I'm working with NumericBox nowadays and I recognised a problem
belong to it. This class is a ComboBox which allows only numeric
values. It use sal_Int64 for store its value but use double conversion
internal for remformating. The problem is that this concept allows
adding such sal_Int64 value which too large (contain too many digits?)
so double conversion changes it in undefined way.
For example: 92 233 720 368 547 750  change to 92 233 720 368 547 744
on my system.

Can you please point exactly to the code in question, like
filename:line_number, or ClassName::MethodName, or something similar?
It helps a lot to understand what you have in mind, and saves the
guessing if it was (in this case) MetricField::ConvertValue() from
vcl/source/control/field.cxx, or something different :-)

In case you mean MetricField::ConvertValue( sal_Int64, ...) that calls
ConvertDoubleValue() as the first thing, I'd probably templatize it like

template <class type>
type implConvertValue( type nValue, sal_Int64 mnBaseValue, sal_uInt16
     nDecDigits, FieldUnit eInUnit, FieldUnit eOutUnit )
{
...
}

double MetricField::ConvertDoubleValue( ...params... )
{
    return implConvertValue< double >( ...params... );
}

sal_Int64 MetricField::ConvertValue( ...params... )
{
    return implConvertValue< sal_Int64 >( ...params... );
}

so that it is not necessary to cast to double and back, and always uses
the expected precision.

All the best,
Kendy



Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.