|
-
Apr 26th, 2005, 08:37 AM
#1
Thread Starter
Member
Converting Double to Int32
when trying to convert a double to an integer, it always rounds up. Say I divide 2 numbers and get .8, it returns one, so what it the code to make it not round up, to return 0 instead? So whats the code to make it return 0, or is there?
-
Apr 26th, 2005, 11:18 AM
#2
Junior Member
Re: Converting Double to Int32
when trying to convert a double to an integer, it always rounds up. Say I divide 2 numbers and get .8, it returns one, so what it the code to make it not round up, to return 0 instead? So whats the code to make it return 0, or is there?
I just tried this:
Code:
int x = (int)(double).8;
MessageBox.Show(x.ToString());
And it returned 0.
Dan
-
Apr 26th, 2005, 11:47 AM
#3
Addicted Member
Re: Converting Double to Int32
You might want to take a look at System.Math.Floor and System.Math.Ceiling functions.
There are no stupid questions, but a whole bunch of dumb sayings !
Save time on database code, try DataLG !
-
Apr 26th, 2005, 12:15 PM
#4
Thread Starter
Member
Re: Converting Double to Int32
ok thanks for the help guys =)
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
|