Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sql Server - Precision handling

I am just reading on the MSDN about Precision Handling.

Taken out from the table on this site:

Operation: e1 / e2

Result precision: p1 - s1 + s2 + max(6, s1 + p2 + 1)

Result scale: max(6, s1 + p2 + 1)

For the explanation of the used expressions:

The operand expressions are denoted as expression e1, with precision p1 and scale s1, and expression e2, with precision p2 and scale s2.

What I do not understand (more like I am not 100% sure I understand it) is this expression

max(6, s1 + p2 + 1)

Can someone explain it to me?

Many thanks :)

like image 372
Dimi Takis Avatar asked May 24 '26 12:05

Dimi Takis


1 Answers

See my worked example here T-SQL Decimal Division Accuracy

It means maximum of 6 or (scale1 + precision2 + 1) for the scale of result

like image 183
gbn Avatar answered May 26 '26 00:05

gbn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!