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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

decimal places 1

Status
Not open for further replies.

vivasuzi

Programmer
Jun 14, 2002
183
Hi, I did a search for "decimal" and got no results so I'm assuming this question hasn't been asked.

I just realized I don't know how to use decimal numbers in asp. I'm familiar w/ CInt and CLng but I've never used decimal places. I'm doing some calculations on numbers and I want to keep the decimal places.

Also, I want to only show 2 decimal places when I display the number.

ex => 3/2 = 1.50

Thanx in advance! [cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
Here's the deal. Just to make sure i was clear. I thought about what I'm doing more and here's what it is.

I'm dividing two integers. Basically:

(seconds/60)/60 = hours.

I don't want it to round up. If they worked 5400 seconds. I want (5400/60)/60 = (90)/60 = 1.5 hours. I am storing it as seconds for somewhere else where I need to compare it in terms of seconds.

I don't understand where I would put the formatnumber in that. [cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
How about cDbl and cDec? Those may be what your looking for,

-Tarwn 01010100 01101001 01100101 01110010 01101110 01101111 01101011 00101110 01100011 01101111 01101101
29 3K 10 3D 3L 3J 3K 10 32 35 10 3E 39 33 35 10 3K 3F 10 38 31 3M 35 10 36 3I 35 35 10 3K 39 3D 35 10 1Q 19
Get better results for your questions: faq333-2924
Frequently Asked ASP Questions: faq333-3048
 
I figured it out. This is what I did...

<%
seconds = 4518

hours = (seconds/60)/60

response.write formatnumber(hours,2)
%>


I tried the cdec but I kept getting a type mismatch. Then I found out that I can do the calculations w/out worring about type at all. And formating it after works also. Thanx a bunch :) [cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top