|
 |
aspx thread: Why are my totals rounded off?
Message #1 by "Jose Haymaker" <ehaymaker@a...> on Mon, 19 Nov 2001 20:10:33
|
|
Abudabi should come out to -2.9, but it results in -3. My total, agape,
should be 287.1, but it displays as 287. All my fields in the table are
float, rather than int. What could be causing this?
Espcially I note if I do this:
response.write (3.1-2.9)
I get 0.2
But if do this:
dim para as integer = 3.1
dim cara as integer =2.9
I get 0!
How do I make it stop rounding off dim'd values?
for i=1 to columns
abba="a"&trim(i)&"domin"
adda="a"&trim(i)&"price"
acca="plusrminus"&i
myCommand3=NEW SQLCommand("SELECT "& adda &", "& acca &" from orders
WHERE vcode='9135' and prodid='911' and "& abba &" = '0'", myConnection)
myDataReader = myCommand3.ExecuteReader()
while myDataReader.Read()
if (mydatareader.item("plusrminus"&i)) = "plus" then
agag=(subtotal * (mydatareader.item("a"&trim(i)&"price"))/100.00)
response.write ("WOW")
response.write (agag)
else
abab=(subtotal * (mydatareader.item("a"&trim(i)&"price"))/100.00)
response.write ("WOOSH")
response.write (abab)
end if
end while
myDataReader.Close()
next
response.write ("<font color=""blue""><b>")
abudabi = ((agag)-(abab))
response.write ((abudabi))
response.write ("</b></font>")
agape= (subtotal + abudabi)
response.write (agape)
Message #2 by Kyle Burns <kburns@c...> on Mon, 19 Nov 2001 15:06:02 -0500
|
|
Jose,
You may want to take a look at the datatype that you are using for your
values. An Integer is designed to hold a whole number value (no decimal
places). See what happens when you change the datatype to something that
can hold a decimal.
=================================
Kyle M. Burns, MCSD, MCT
ECommerce Technology Manager
Centra Credit Union
kburns@c...
-----Original Message-----
From: Jose Haymaker [mailto:ehaymaker@a...]
Sent: Monday, November 19, 2001 3:11 PM
To: ASP+
Subject: [aspx] Why are my totals rounded off?
Abudabi should come out to -2.9, but it results in -3. My total, agape,
should be 287.1, but it displays as 287. All my fields in the table are
float, rather than int. What could be causing this?
Espcially I note if I do this:
response.write (3.1-2.9)
I get 0.2
But if do this:
dim para as integer = 3.1
dim cara as integer =2.9
I get 0!
How do I make it stop rounding off dim'd values?
for i=1 to columns
abba="a"&trim(i)&"domin"
adda="a"&trim(i)&"price"
acca="plusrminus"&i
myCommand3=NEW SQLCommand("SELECT "& adda &", "& acca &" from orders
WHERE vcode='9135' and prodid='911' and "& abba &" = '0'", myConnection)
myDataReader = myCommand3.ExecuteReader()
while myDataReader.Read()
if (mydatareader.item("plusrminus"&i)) = "plus" then
agag=(subtotal * (mydatareader.item("a"&trim(i)&"price"))/100.00)
response.write ("WOW")
response.write (agag)
else
abab=(subtotal * (mydatareader.item("a"&trim(i)&"price"))/100.00)
response.write ("WOOSH")
response.write (abab)
end if
end while
myDataReader.Close()
next
response.write ("<font color=""blue""><b>")
abudabi = ((agag)-(abab))
response.write ((abudabi))
response.write ("</b></font>")
agape= (subtotal + abudabi)
response.write (agape)
---
VBug Winter Conference 2001
Open Forum: Dan Appleman will be hosting an open
forum at The .NET Developer's Conference on
29th November 2001. The session will give
developers the chance to discuss and question
Dan on his experience with the .NET environment.
Dan has been programming Visual Basic since the
alpha version 1.0. And with over 10 years
Visual Basic experience is well qualified to
help you on your road to being a .NET Guru.
http://www.vbug.co.uk/redirect.asp?url=39&id=17
---
You are currently subscribed to
aspx as: kburns@c...
$subst('Email.Unsub')
Message #3 by "S. Asif Imam" <asifimam@y...> on Tue, 20 Nov 2001 09:50:37 +0500
|
|
I dont know what you are trying to do in this code but any way I feel this
will help
Instead
> dim para as integer = 3.1
> dim cara as integer =2.9
use
dim para as Double = 3.1
dim cara as Double =2.9
Integer data type works for absolute values and will alwys round off the
given number, While Double will takeit as it is .
So where ever you are using Integer replace it with Double data type.
Happy !
----- Original Message -----
From: "Jose Haymaker" <ehaymaker@a...>
To: "ASP+" <aspx@p...>
Sent: Monday, November 19, 2001 8:10 PM
Subject: [aspx] Why are my totals rounded off?
> Abudabi should come out to -2.9, but it results in -3. My total, agape,
> should be 287.1, but it displays as 287. All my fields in the table are
> float, rather than int. What could be causing this?
>
>
> Espcially I note if I do this:
> response.write (3.1-2.9)
> I get 0.2
>
> But if do this:
>
> dim para as integer = 3.1
> dim cara as integer =2.9
> I get 0!
>
> How do I make it stop rounding off dim'd values?
>
> for i=1 to columns
>
> abba="a"&trim(i)&"domin"
> adda="a"&trim(i)&"price"
> acca="plusrminus"&i
>
> myCommand3=NEW SQLCommand("SELECT "& adda &", "& acca &" from orders
> WHERE vcode='9135' and prodid='911' and "& abba &" = '0'", myConnection)
> myDataReader = myCommand3.ExecuteReader()
>
>
> while myDataReader.Read()
>
> if (mydatareader.item("plusrminus"&i)) = "plus" then
>
> agag=(subtotal * (mydatareader.item("a"&trim(i)&"price"))/100.00)
> response.write ("WOW")
> response.write (agag)
>
>
>
> else
>
> abab=(subtotal * (mydatareader.item("a"&trim(i)&"price"))/100.00)
> response.write ("WOOSH")
> response.write (abab)
>
> end if
> end while
> myDataReader.Close()
>
> next
>
> response.write ("<font color=""blue""><b>")
>
> abudabi = ((agag)-(abab))
> response.write ((abudabi))
> response.write ("</b></font>")
>
> agape= (subtotal + abudabi)
> response.write (agape)
> ---
> VBug Winter Conference 2001
>
> Open Forum: Dan Appleman will be hosting an open
> forum at The .NET Developer's Conference on
> 29th November 2001. The session will give
> developers the chance to discuss and question
> Dan on his experience with the .NET environment.
> Dan has been programming Visual Basic since the
> alpha version 1.0. And with over 10 years
> Visual Basic experience is well qualified to
> help you on your road to being a .NET Guru.
>
> http://www.vbug.co.uk/redirect.asp?url=39&id=17
>
> ---
> You are currently subscribed to
> aspx as: asifimam@y...
> $subst('Email.Unsub')
|
|
 |