How can I easily convert a decimal fraction to an integer, example: if I have a value of 13,2 I need to show an integer value of 2
Printable View
How can I easily convert a decimal fraction to an integer, example: if I have a value of 13,2 I need to show an integer value of 2
Will there always be only one decimal place, or will the length be arbitrary?
13,2
.132
13.2
none of the above
13,2 isn't a decimal fraction.
i don't understand the question
Ditto. There is no such thing as a decimal fraction. A fraction is one integer divided by another, like 3/8 or 11/16.
I think that people in England use commas in place of decimals or something..
Yeah, I thought of that too, but I still know how you'd convert 13.2 to 2. OP needs to explain his problem a little better...
Change the periods to commas if that's what your system uses as a decimal place.Code:Dim d As Decimal = 13.2
Dim arrSplit As String() = d.ToString.Split(".")
Dim i As Integer = Integer.Parse(arrSplit(1))
I think there's an example on how to do this in the code bank of these forums.
Also, from the example you provide, it seems like you want to get all the numbers after the decimal point. This doesn't really have anything to do with fractions or integers. Although, as Tom suggested, you can use the Split function, if they even is what you want to do.Quote:
Originally Posted by snufse
Or you can simply write...Quote:
Originally Posted by Tom Sawyer
Code:Dim MyDec As Decimal = 13.2
MessageBox.Show(MyDec.ToString.Split("."c)(1))
Might also want to convert the final answer to a string before putting it into a message box.
vb.net Code:
Dim MyDec As Decimal = 13.2 MessageBox.Show(MyDec.ToString.Split("."c)(1).ToString())
no they don't.Quote:
Originally Posted by Fromethius
Well, a lot of countries still do.
http://en.wikipedia.org/wiki/Decimal...#Dot_countries
http://en.wikipedia.org/wiki/Decimal...omma_countries