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


ADVERTISEMENT

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

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 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

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

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

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

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 View Related

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

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

ROUND Up

I have the following equation.

<% varWT = Round(CInt((rsFreePack.Fields.Item("Weight").Value)) +
CInt(Session("w"))) %>

Assume....
Round(CInt((rsFreePack.Fields.Item("Weight").Value)) = .12
CInt(Session("w")) = 30

How can I get it to always ROUND up to 31 ...?

View Replies View Related

Round Up

I have a number with a decimal point that i always want to round upwards to the nearest whole number.Now i can use the round(No.) function and this works for any value of .5 and above the problem is the lower .1 .2 .3 .4.So an example

if i get the number 14.2 i want the output to be 15

11.3 = 12
13.8 = 14

View Replies View Related

Round Up

If I have a value that is 53.123499999, how can I round it to 53.12?

View Replies View Related

Round A Variable

I have a variable (ex. 5.66666666) and I want to round it to 2 decimal places. Anyone got this code?

View Replies View Related

How To Round Up A Whole Number?

I've created a freight calculator that needs to know how many pallets I'm shipping. I'm using 1 pallet for 750lbs and an extra pallet for anything more than that.

If materialWeight <= 750 Then numPallets = 1 Else numPallets = Round(materialWeight / 750) End If

Now, let's say the materialWeight/750 ends up being 3.2. This is returning 3, but I need it to return 4 since we need an extra pallet.

How can I make it Round up to the next whole number? If it turned out to be an exact number without a decimal then it should stay where it is, but if it's over x.0 at all it should go up to the next whole number.

View Replies View Related

Round() Vs FormatNumber()

I'm working on finishing a project the was started by someone else who no longer works here. Its an asp page that takes a whack of numbers form a db, and makes em look all pretty in tables. (its a remake of an excel spreadsheet)
the problem is some of the numbers are not apearing properly. I'm thinking it's because they used Round() sometimes and formatNumber() other times.
the question is... do these functions handle numbers differently? i know formatNumber can do more then just round but i just need it to make the numbers 1 or 2 decimals.

View Replies View Related

Round Numbers To 0

I want to round numbers to include a 0 at the end.

response.write "<td bgcolor=white align=center class=menuText>" & 100 - Round(CTASCAvail,2) & "%</td>"
response.write "<td bgcolor=white align=center class=menuText>" & 100 - Round(Avail,2) & "%</td>"

the following code will round the numbers 2 decimal places but if it is a 0 it will not display it.

View Replies View Related

Round Time

Does anyone know how I could round the minutes to the nearest 15 minutes, I'm using this

%=minute(now()) %>

View Replies View Related

Round Up Number

Given: total = 18.01

I use FormatNumber(total,2), it give me 18.01
I use FormatNumber(total,0) it give me 18

I wanna to get 19, how should i do the code?? if there is any decimal
value, i wanna round it up to the next whole number.

View Replies View Related

Round A Number Up

I am dividing a value by two .. what i need is to round the number up if it is not a whole number.

View Replies View Related

Round Up A Figure

for eg x = 3.14. I want to do a round up to 1 decimal. if I were to use round(3.14) , I will get 3.1 , however I want to round up , expecting to get 3.2 .

View Replies View Related

Round Upwards

In ASP, how do I do this?

Like 1.5 ---> 2
1.001 ---> 2
4.3---> 5
5.0001---> 6

View Replies View Related

Round Numbers

how to round off numbers i have tried 2 different ways but hitting the dead end. say for example the number stored in my variable is

strnum="112"

i want to round it to 115 so my new value will be strnum="115" . so if its 113 it should be rounded to 115 . if its 116 or 117 or 118 or 119 it should be 120 . if its 111 or 112 or 113 it should be 115 . how i can round the numbers.

View Replies View Related

Math.round

How can I round the value to the nearest whole number. I have searched on math.round but
can not get it to function. Here is how I am getting the results if not division by zero. Code:

View Replies View Related

Round Function

If I have a number that looks like 32.3, 15.5, 30.1 etc, I always assumed Price = Round(Price,2) is actually rounding a figure into a whole number or putting 32.30 etc.

So how do you exactly round the figure to whole number or put a zero at the end of it. I was thinking of formatNumber but I can't remember if there is a function for that?

View Replies View Related

Next Round In Loop

I looped a record set to display and I found a strnage thing. as

Do While NOT rsBinAct.EOF

l_bin = rsBinAct.Fields("o_bin")
l_niin = rsBinAct.Fields("o_bin_niin")
l_b = LEFT(l_niin, 3)
l_n = RIGHT(l_niin, LEN(l_niin)-3 )

' display l_bin, l_b, l_n in a table-like page

rsBinAct.MoveNext
Loop

If I do not set the l_b and l_n to NULL then if the next l_niin is null value, I will get the l_n value of previous one only, l_b is still null. I wonder why.

View Replies View Related







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