|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Round and rounding roules.We have a question regarding rounding of values. From Books online: SELECT ROUND(123.4545, 2); Results in 123.4500 Why not 123.46 In 123.4545 the last digit(5) pushes the 4 up to 5 and that again pushes the second digit from 5 to 6. Isn't that the roule? All this comes from the use of Real values. We are changing this to decimal(x,y) values to avoid the confusion, but any explanations would be nice. I would expect 5725.93 in the following example. Using decimal I get this correct. PS: And if anyone could explain this to me in a way that my boss understand I will be impressed :-) /**** EXAMPLE *******/ declare @b money declare @r money declare @e smallint declare @a real --declare @a decimal (19,6) set @b = 5725.925 set @a = 100.00 set @e = 100 set @r = ((@b / @a) * @e) select @r as r, round(@r,2) as r_avr, cast(@r as decimal(9,2)) as r_cast *********************************'' -- Thanks all Regards Geir
Other interesting topics
|
|||||||||||||||||||||||