Rounding Decimals In Asp

How round a number in ASP, so you have a certain number of decimal places. We will perform a very simple exercise which is round a figure, so have the number of decimal places you want. Rounding off decimals in ASP is very simple, thanks to a Visual Basic Script called Round() function. Function Round() the Round() function receives two parameters, the number that you want to round and the number of decimal places that you want to have: Round (number, Num_digits) returns the number rounded so you have as many decimal places as you send in the second parameter. The second parameter is optional and if not indicated, understand that want to round without decimals.

The Round() function always rounds to the nearest value with the specified Decimal. Possible examples, which can give us an accurate idea of the way of working of Round(), are: Round (2.2) returns 2 Round (2.6) returns 3 Round (41.2855,3) returns 41.286 Round (41.2009,2) returns 41.2 Round (41.2009,3) Returns 41.201 functions Int() and Fix() these two functions are related with Round(). They serve to obtain the integer portion of a number with decimals. There are no differences between Int() and Fix(), both do exactly the same thing. Let’s look at a couple of examples: Int (54.23) returns 54 Fix (0.2) returns 0 as we see, is not a rounding, but obtaining the integer once we have removed decimals. Miguel Angel Alvarez Director of original author and source of the article

Both comments and pings are currently closed.