Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate percentage 1

Status
Not open for further replies.

perryair

IS-IT--Management
Apr 7, 2005
91
0
0
IL
Hi,
I am using asp code in order to calculate non integer number.. any iday what the correct syntax is?

10 should be 10.5%

<%= formatNumber((intTotal * .10), 2) %>

Many Thanks...
 
didnt understand the question completely...try using cdbl() function for the floating numbers...

-DNG
 
Try making a separate simple ASP like this below to help debug and figure out how floating points are handled.
Code:
<%
x = 22 / 7
Response.Write "With function: "FormatNumber(x, 2) & "<BR>" & vbCrLf
Response.Write "Without: " & x
%>
 
Sorry, I did not understand both of you..
It should be very simple.. instead of 10 I would like to make it 10.5, does anyone know what is the syntax?
 
Oh, perhaps I didn't understand the question.

Are you asking how to calculate 10.5% of a value?

X = Y * .105
 
perryair said:
10 should be 10.5%

<%= formatNumber((intTotal * .10), 2) %>
I assume that 10.5% should be the result of the formula you have above. Simply take your calculation and, instead of using FormatNumber as you have, use FormatPercent instead. For more help on this, try MSDN

------------------------------------------------------------------------------------------------------------------------
"I am not young enough to know everything."
Oscar Wilde (1854-1900)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top