April 16, 2014 | Posted in: .Net

There may be legitimate circumstances where you want to store a specific decimal value and you don’t want SQL Server to round that precision off which would give you incorrect results when multiplying by large numbers.

Example 10.73085 stored in a SQL Server decimal 18,4 will round up and be stored as 10.7309. If like me you wanted to keep the 4 decimal place precision without round up there is a way.

(Math.Floor(value * 10000) / 10000)

Just specify a zero for each decimal place you wish to keep i.e. * 1000 for 3dp, * 100 for 2 dp and so on.

Be the first to comment.

Leave a Reply

*


1 × two =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>