By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,326 Members | 881 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,326 IT Pros & Developers. It's quick & easy.

some numeric function

P: n/a
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)
also get the reminder y = 15/6 , i can get the result (3)

Thanks
Nov 20 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Look at the system.Math namespace, there is a round function within there
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uB****************@TK2MSFTNGP12.phx.gbl...
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)
also get the reminder y = 15/6 , i can get the result (3)

Thanks

Nov 20 '05 #2

P: n/a
Hi Agnes,

Watch the rounding in dotNet, the only posibility is the banker's rounding.
Do you use that in Honkong, because I ask it to everybody however never got
an answer and I am curious where it is used.

For the rest of your question you have to look at the different values, they
all are for this reason.

Numeric datatypes
http://msdn.microsoft.com/library/de...cdatatypes.asp

Rounding
http://msdn.microsoft.com/library/de...oundtopic1.asp

Cor
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)
also get the reminder y = 15/6 , i can get the result (3)

Thanks

Nov 20 '05 #3

P: n/a
Thanks a lot

"microsoft" <as*******@hotmail.com> 在郵件
news:eE**************@TK2MSFTNGP12.phx.gbl 中撰寫...
Look at the system.Math namespace, there is a round function within there
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uB****************@TK2MSFTNGP12.phx.gbl...
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)
also get the reminder y = 15/6 , i can get the result (3)

Thanks


Nov 20 '05 #4

P: n/a
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:uB****************@TK2MSFTNGP12.phx.gbl...
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)
also get the reminder y = 15/6 , i can get the result (3)


if you want "15/6" to give you "2":

dim whole as Integer
whole = Int(15/6)

That will do the division, which will give you a real number (with possible
decimals), and just take the integer portion of the answer.
To get the remainder you need to do the MOD function:

dim remainder as Double
remainder = 15 Mod 6
remainder will now equal 3.

Nov 20 '05 #5

P: n/a
Agnes wrote:
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)


You can also use

Dim whole as Integer
whole = 15 \ 6

This performs an integer division -- i.e., it discards the fractional part
of the result (rounds down).

--

(O)enone
Nov 20 '05 #6

P: n/a
Thanks To all.
I solve my numeric problem ~~~~

"Oenone" <no***@nowhere.com> 在郵件
news:e5**************@TK2MSFTNGP09.phx.gbl 中撰寫...
Agnes wrote:
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)


You can also use

Dim whole as Integer
whole = 15 \ 6

This performs an integer division -- i.e., it discards the fractional part
of the result (rounds down).

--

(O)enone

Nov 20 '05 #7

P: n/a
"Oenone" <no***@nowhere.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
Agnes wrote:
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)


You can also use

Dim whole as Integer
whole = 15 \ 6

This performs an integer division -- i.e., it discards the fractional part
of the result (rounds down).


So it will automatically covert the answer to whatever type the receiving
variable is? Do all functions in VB.NET round down no matter what? even for
say 1.999?
Nov 20 '05 #8

P: n/a
Ricky,
In addition to integer division you could use the Math.Round function.

x = Math.Round(15/6, 0)

http://msdn.microsoft.com/library/de...hfunctions.asp

Hope this helps
Jay

"Ricky W. Hunt" <rh*****@hotmail.com> wrote in message
news:posNc.39982$eM2.20658@attbi_s51...
"Oenone" <no***@nowhere.com> wrote in message
news:e5**************@TK2MSFTNGP09.phx.gbl...
Agnes wrote:
Where I can find the tutorial about numeric function..
e.g x = 15/6, i need to get the result (2) but not (2.5)
You can also use

Dim whole as Integer
whole = 15 \ 6

This performs an integer division -- i.e., it discards the fractional part of the result (rounds down).


So it will automatically covert the answer to whatever type the receiving
variable is? Do all functions in VB.NET round down no matter what? even

for say 1.999?

Nov 20 '05 #9

P: n/a
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Ricky,
In addition to integer division you could use the Math.Round function.

x = Math.Round(15/6, 0)


Thanks.
Nov 20 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.