443,326 Members | 881 Online 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
9 Replies

 P: n/a Look at the system.Math namespace, there is a round function within there "Agnes" 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" ¦b¶l¥ó news:eE**************@TK2MSFTNGP12.phx.gbl ¤¤¼¶¼g... Look at the system.Math namespace, there is a round function within there "Agnes" 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" 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" ¦b¶l¥ó news:e5**************@TK2MSFTNGP09.phx.gbl ¤¤¼¶¼g... 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" 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" wrote in message news:posNc.39982\$eM2.20658@attbi_s51... "Oenone" 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]" 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. 