I always read that I should use decimal
or similar for money and financial calculations (example). However as much I can see, all of the Business One SDK uses double
s? Is this okay? Am I expected to convert the double values to decimals every time I am doing calculations, than back to double If I want to set it for an API object (what I do currently)?
Note: The SQL database uses numeric(19,6)
for these values.
Despite what it might look like in Visual Studio, the SAP SDK isn't really a .Net-native library - it's a .Net wrapper over a C/C++ dll using COM Interop.
I don't think that decimal
is a native type in C/C++, and it's certainly not a basic/intrinsic type in .Net (unlike e.g. string
, int
, double
, etc) - it's also slower to use because there's no intrinsic CPU instructions for Decimal operations (unlike the basic types).
Because there's no equivalent in C/C++, it would have to be translated to a type that can be understood by the underlying library - and that type would likely be double
anyway.