some numeric function

  • Thread starter Thread starter Agnes
  • Start date Start date
A

Agnes

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
 
Look at the system.Math namespace, there is a round function within there
 
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/d...ry/en-us/vbcn7/html/vbconnumericdatatypes.asp

Rounding
http://msdn.microsoft.com/library/d...pref/html/frlrfsystemmathclassroundtopic1.asp

Cor
 
Agnes said:
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.
 
Agnes said:
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).
 
Thanks To all.
I solve my numeric problem ~~~~

Oenone said:
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).
 
Oenone said:
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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top