# formating number

Discussion in 'ASP General' started by Jeff, Nov 9, 2006.

1. ### JeffGuest

hey guys

If i wish to show a decimal on a number, i can do this

v2_score = formatnumber(v2_score1, 0)

but how would i only show the 2 decimal places IF there is an actual
remainder after the division?

here is the script and stuff
using sql db server

v2_score1 = v_score / v_played
v2_score = formatnumber(v2_score1, 0)

v_score is an over all total in the db
v_played is how many matches were played.

any help please.... and thank you??

Jeff, Nov 9, 2006

Use the MOD function,
this will return the numbers after the point

example
a) 42/100 = 0.42
b) 42 mod 100 = 42

SO if you have a result to the MOD sum, you can show
with the formatting, if no result, you can show with out the formatting

Mike.

"Jeff" <> wrote in message
news:...
> hey guys
>
> If i wish to show a decimal on a number, i can do this
>
> v2_score = formatnumber(v2_score1, 0)
>
> but how would i only show the 2 decimal places IF there is an actual
> remainder after the division?
>
> here is the script and stuff
> using sql db server
>
> v2_score1 = v_score / v_played
> v2_score = formatnumber(v2_score1, 0)
>
> v_score is an over all total in the db
> v_played is how many matches were played.
>
> any help please.... and thank you??
>