|
-
Jan 11th, 2008, 12:16 PM
#1
Thread Starter
Fanatic Member
Convert decimal fraction to integer
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
-
Jan 11th, 2008, 12:19 PM
#2
Re: Convert decimal fraction to integer
Will there always be only one decimal place, or will the length be arbitrary?
My usual boring signature: Nothing
 
-
Jan 11th, 2008, 12:31 PM
#3
Re: Convert decimal fraction to integer
13,2
.132
13.2
none of the above
-
Jan 11th, 2008, 01:09 PM
#4
Re: Convert decimal fraction to integer
13,2 isn't a decimal fraction.
i don't understand the question
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 11th, 2008, 03:46 PM
#5
Frenzied Member
Re: Convert decimal fraction to integer
Ditto. There is no such thing as a decimal fraction. A fraction is one integer divided by another, like 3/8 or 11/16.
-
Jan 11th, 2008, 03:50 PM
#6
Frenzied Member
Re: Convert decimal fraction to integer
I think that people in England use commas in place of decimals or something..
-
Jan 11th, 2008, 03:55 PM
#7
Frenzied Member
Re: Convert decimal fraction to integer
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...
-
Jan 11th, 2008, 04:01 PM
#8
Re: Convert decimal fraction to integer
Code:
Dim d As Decimal = 13.2
Dim arrSplit As String() = d.ToString.Split(".")
Dim i As Integer = Integer.Parse(arrSplit(1))
Change the periods to commas if that's what your system uses as a decimal place.
-
Jan 11th, 2008, 04:02 PM
#9
Frenzied Member
Re: Convert decimal fraction to integer
I think there's an example on how to do this in the code bank of these forums.
-
Jan 11th, 2008, 04:05 PM
#10
Frenzied Member
Re: Convert decimal fraction to integer
 Originally Posted by snufse
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
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.
-
Jan 11th, 2008, 04:34 PM
#11
Re: Convert decimal fraction to integer
 Originally Posted by Tom Sawyer
Code:
Dim d As Decimal = 13.2
Dim arrSplit As String() = d.ToString.Split(".")
Dim i As Integer = Integer.Parse(arrSplit(1))
Change the periods to commas if that's what your system uses as a decimal place.
Or you can simply write...
Code:
Dim MyDec As Decimal = 13.2
MessageBox.Show(MyDec.ToString.Split("."c)(1))
-
Jan 11th, 2008, 04:47 PM
#12
Frenzied Member
Re: Convert decimal fraction to integer
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())
-
Jan 11th, 2008, 07:54 PM
#13
Re: Convert decimal fraction to integer
 Originally Posted by Fromethius
I think that people in England use commas in place of decimals or something..
no they don't.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jan 11th, 2008, 08:02 PM
#14
Frenzied Member
Re: Convert decimal fraction to integer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|