We have a number of fields defined as numeric(38,20) – because the data travels to an ORACLE db with that scale/precision.
When performing calculations, rounding tends to happen between 12 and 14 decimal places (depending). I tested various combinations of float/decimals in hopes of keeping precision and store back into numeric(38,20)
e.g.
enter code here
declare @dtest20 decimal(38,20) = cast( 1.44444444441234567892 as decimal(38, 20))
declare @ftest20 float = cast( 1.44444444441234567892 as float)
declare @f100 float = cast( 100.0 as float )
declare @d100 decimal(38,20) = cast( 100.0 as decimal(38,20))
select @dtest20 * @d100 as 'dtest20 x d100'
, cast( @dtest20 * @d100 as decimal(38,20)) as 'dtest20 x d100'
, @ftest20 * @f100 as 'ftest20 x f100'
, cast( @ftest20 * @f100 as decimal(38,20)) as 'ftest20 x f100'
dtest20 x d100 dtest20 x d100 ftest20 x f100 ftest20 x f100 144.444444 144.44444400000000000000 144.444444441235 144.44444444123457000000
I know this is really an MS-SQL thing, but is there any work around/recommendation to perform calculations on large precision numbers and avoid inadvertent rounding?
Thanks!