Rounding Of Number To 2 Decimal

how do i round off a number to 2 decimal places? This code taken from www.w3schools.com only round the number to a whole number.

<html>
<body>

<script type="text/vbscript">
i = 48.66776677
j = 48.999
document.write(Round(i))
document.write("<br />")
document.write(Round(j))
</script>

</body>
</html>

View Replies


ADVERTISEMENT

Rounding To 2 Decimal Places

I have got the total amount of hours flown in the top left hand side of the home page and it is in hours.

Trouble is the decimal places need to be rounded to 2 as sometimes it says sometihg like 3254.63333333333 hours. I'd like it to say something like 3254.63 instead.. Code:

View Replies View Related

Rounding Off To 2 Decimal Places

can anyone help me i want to round off a number entered by a user to two decimal points for a number of text boxes.

View Replies View Related

Rounding Down Number

If CInt(StrFirst) rounds up the value what rounds down the number i.e just show the whole number with out taking in to account anything after the decimal point?

View Replies View Related

Trimming Or Rounding Up A Number

if i have a value of 11.7908787541713

how could i trim it to 11.79 and how do i round the number up?

View Replies View Related

Is Decimal Number Between

How do I write? Code:

Dim johnson, jordan

decnum = Request.Form("decnum")
decnum = Cdbl(decnum)

If decnum is "a decimal number" between 4 AND 8 Then
jordan = 23.90
End If

View Replies View Related

Number Formating Decimal Places Not To Remove Zero 0 At The End

I have a report that will format a number to the last 2 decimal places. However it will trim off the 0 at the end. Example.

98.90 is formated to 98.9

how can i tell the format number function to not trim the 0 but still have the last 2 digits.

View Replies View Related

Rounding Off

I need to round off a few fields to 1 or 2 decimal places but if the number is negative, it gives -0.0 or -0.00 after rounding off. Eg. -0.001356 after rounding off to two decimal places gives me -0.00...which is meaningless as -0.00 is useless Also, -0.019 should give -0.02.Tried using FormatNumber and Round functions in VBScript but still it gives the same results.

View Replies View Related

Rounding Down/up?

I have a page in witch 4 or so variables are loaded from a database. They are of currency format and then they are add up to get a total. Problem is that say the total is $6.10 the actual return is rounded down to $ 6.1 . How can I get it to show $6.10 , less rounding ??

View Replies View Related

Round() :: Rounding Bug

i have a very simple question which is driving me nuts. Using the ASP function Round():

Why do BOTH Round(1.775, 2) and Round(1.785, 2) both give the exact same result of 1.78 ?

Surely they should give different results, 1.78 and 1.79 respectively.

View Replies View Related

Rounding The Numbers

I'm using asp, obviously, and mysql. My prices are using the decimal field type... what can I do to make it round up the the nearest 5?

View Replies View Related

Rounding Numbers

I've got this script, and its been giving me this result as seen below. 2 questions I would like to ask..

1. How would I modify the below script in order to round the numbers?. (Script further down.)

2.You see the output result where it says 3268.19?, the white space next to it means the 'Parts' record set is blank but did have a weight value, now how would I substitute the word "NA" for the white space being shown? .....

View Replies View Related

Rounding Numbers

I'm trying to work out how I can round off a number that the user inputs. I need the number to round up to the nearest 50. For example, if the user enters 234, I want it to round up to 250. If the user enters 51, I want it to round up to 100. Has anyone got any suggestions for coding?

View Replies View Related

Rounding Numbers Up

I am working on a shipping calculator, and basically need to round up a number to the nearest 1 and am unsure how to go about it, any ideas?

View Replies View Related

Rounding Decimals 2 Places

Right now I round my number to 2 decimal places... and since I am dealing with money values I need to show $100.70...but my calculations show $100.7. Is there a way to fix this? How can I tack on a "0" if it only shows 1 decimal place?

View Replies View Related

Caluclating And Rounding Time In Asp

I'm trying to calculate two time fields. And when the result is smaller then 15 min, it has to round it to 15 min. Example:

begin time: 14:00
end time: 14:40
(end time - begin time = 40 minutes)
result has to be: 45 minutes

The result wil be shown in a form field. This is the code I'm using (it works fine in my database), perhaps I have to adjust it for asp? But I don't know how. Code:

View Replies View Related

Dividing Variables And Rounding

I'm doing up a stats page for a survey, and this is a small
part of one of the results. Below is part of the code to do
totals/percents. My question is, how do i make it so myAnswer is
written with two decimal places?

Currently, it displays the percent as 4.76190476190476

<%
myAnswer = OneAgree_total / OneTotal_total * 100
Response.Write "" & myAnswer
%>

View Replies View Related

Rounding On Calculated Field

Is there a way to round a number that is calculated in an sql statement?

1/25/2006 NT NT 10 NT
1/26/2006 450000 NT 10 NT
1/26/2006 200100 5 NT 5
1/26/2006 50000 5 NT 5
Average 233366.6667 5 10 5

On my average row, i dont want any numbers after the decimal point. My sql is Select AVG(XXX) from `test` Where `XXX` <> -1

View Replies View Related

Num To String Conversion Rounding Issue

I had recently found a function that will write out a currency amount in words. It worked fine until I passed it a variable retreived from the stored procedure.

Well I had to change an "Int()" to "CDbl()" within the function because I got an error: "Variable uses an Automation type not supported in VBScript". I also changed an "(Abs(nAmount)" to an "(Abs(CDbl(nAmount))" because of the same error. Code:

View Replies View Related

Decimal

if there is an easy way to convert hex to decimal with asp, the hex() function is there to get the decimal to hex, but i haven't been able to find a way to go back.

View Replies View Related

Decimal Value

I want to convert a number to percentage or decimal,is there any built-in function for this?

View Replies View Related

Decimal Value

i want to do the calculation like

value=int(basic) * int(excise) / 100

the both value come from the form. so when the data of excise field is like decimal 16.32 then i get the error data type mismatch.because the excise is 16.32 it is a decimal value. i have used CDbl(excise) but still it gives error.

View Replies View Related

Decimal Value

My ASP driven site has always used MySQL as the DB backbone, mainly as the hosting costs of MySQL are far cheaper than SQL Server at the mo, and it has worked fine until my ISP thought that they were doing everybody a favour by upgrading to v5 from v4.

What happens now is that any ASP query that I do that involves any of my MySQL Decimal data type fields goes belly up. It will not work. Looks to be an issue with ASP, MyODBC and MySQL, but I just wanted to check if there was a better/more reliable data type than Decimal (which obviously performs the same numerical functions) and if there was a quick way to convert all of my Decimal fields to this new type.

View Replies View Related

Decimal Value

Testing a ASP page using an Access db and I have a field in the DB defined as a 'number' with a precision of 3. Upon submitting the test data, I get this error message.


Microsoft JET Database Engineerror '80040e21'Scaling of decimal value resulted in data truncation. Can anyone tell me what's going on? The test value I used was "2.5".

View Replies View Related

Hex To Decimal

Is there a quick function to check if a passed value is a valid Hex Color? ie, if FD4323 was passed, it would return TRUE, and if FD94LR was returned it would return FALSE.

I'm finding conversion functions, but nothing that tests off hand.

View Replies View Related

Two Decimal Places

I have searched the forum and found the answer to my problem but unfortunitly it didn't tell me how to implement the solution!
The code I have thanks to previous forums:
Code:

<%=(rs("Seconds")/60=FormatNumber(2.5,2))%>

Basiclly I want to convert the seconds to minutes and round to two decimal places.

View Replies View Related

Decimal Conversion

Anyone have any code handy to convert a binary number to decimal and a decimal to binary? I need server-side code to perform these calculations. For example, I'd like to be able to pass 129 to a function and it will return 10000001. Likewise, I'd like to pass 10000001 to a function and get 129.
I can do this on paper, just not sure where to start on how to pass these numbers into a function to perform the calculation.

View Replies View Related

Decimal Problems

i have a script that calculates a value but when the value is for example 5.40 the textbox displays it as 5.4 because this is a money value it has to have the "0" at the end
how can i make the script so that it always has 2 decimals behind the comma or point. Code:

View Replies View Related

My Decimal Is Being Rounded Up By SQL

I have a form in an ASP page that the user enters a price for. When I send the parameter to my SQL stored Proc and refresh the data, it gets rounded up to the nearest integer. I can change the data just fine in SQL but not by using my asp page. Can anyone point me in the correct direction?

View Replies View Related

Decimal Numbers

i have the following equation:

<%
avg_score = total / count_match
%>

what can i do to restrict the result of avg_score to be of 2 decimal places?

View Replies View Related

Set Decimal Places

I need to truncate a number to two decimal places without rounding. All the functions i;ve tried tend to round up the numbers. Also i cant use any string functions to limit the size because the size can vary. example, 34.56998 must be set to 34.56 .

View Replies View Related

How To Limit A Decimal

I have some calculations in my query string. Is it possible somehow to get a results of those calculations not in decimals but in integer in the query itself.

View Replies View Related

Different Decimal Symbol

I have ASP code displaying currency datatype data from Access database. I have copies of this asp code and tha database on two w2k/IIS5 computers, bothg having the decimal symbol set to "." in the Regional setting both for numbers and for currency. However on one PC it shows dots, while on the other - commas. What is actually controlling which decimal shows up?

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved