Click here to Skip to main content
15,887,683 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionConvert from Double to Integer w/o Rounding in C++ Pin
User 741604624-Feb-11 12:06
User 741604624-Feb-11 12:06 
AnswerRe: Convert from Double to Integer w/o Rounding in C++ Pin
Luc Pattyn24-Feb-11 12:30
sitebuilderLuc Pattyn24-Feb-11 12:30 
GeneralRe: Convert from Double to Integer w/o Rounding in C++ Pin
User 741604624-Feb-11 13:31
User 741604624-Feb-11 13:31 
QuestionRe: Convert from Double to Integer w/o Rounding in C++ Pin
Luc Pattyn24-Feb-11 13:42
sitebuilderLuc Pattyn24-Feb-11 13:42 
AnswerRe: Convert from Double to Integer w/o Rounding in C++ Pin
«_Superman_»24-Feb-11 18:51
professional«_Superman_»24-Feb-11 18:51 
AnswerRe: Convert from Double to Integer w/o Rounding in C++ Pin
Bernhard Hiller24-Feb-11 20:56
Bernhard Hiller24-Feb-11 20:56 
AnswerRe: Convert from Double to Integer w/o Rounding in C++ Pin
Andrew Brock24-Feb-11 22:20
Andrew Brock24-Feb-11 22:20 
GeneralRe: Convert from Double to Integer w/o Rounding in C++ Pin
User 741604625-Feb-11 2:44
User 741604625-Feb-11 2:44 
Thanks.

I thought I read somewhere that int() rounded down when converting from double, though it didn't seem so when I tested it. I think the whole thing that brought up this issue was the fact that int() doesn't handle decimals like 1.99999... correctly. Therefore it was throwing off everything when it rounded 1.999... to 2.

The above function works perfectly, so long as you make sure to include both float.h and cmath.

Thanks again!

modified 21-Dec-20 21:02pm.

QuestionHow can I retrieve handlw of dropdown list box ? Pin
_Flaviu24-Feb-11 5:20
_Flaviu24-Feb-11 5:20 
AnswerRe: How can I retrieve handlw of dropdown list box ? Pin
Hans Dietrich24-Feb-11 5:31
mentorHans Dietrich24-Feb-11 5:31 
GeneralRe: How can I retrieve handlw of dropdown list box ? Pin
_Flaviu24-Feb-11 7:02
_Flaviu24-Feb-11 7:02 
AnswerRe: How can I retrieve handlw of dropdown list box ? Pin
Code-o-mat24-Feb-11 8:33
Code-o-mat24-Feb-11 8:33 
GeneralRe: How can I retrieve handlw of dropdown list box ? Pin
_Flaviu24-Feb-11 9:52
_Flaviu24-Feb-11 9:52 
GeneralRe: How can I retrieve handlw of dropdown list box ? Pin
Code-o-mat24-Feb-11 9:54
Code-o-mat24-Feb-11 9:54 
GeneralRe: How can I retrieve handle of dropdown list box ? Pin
_Flaviu24-Feb-11 22:03
_Flaviu24-Feb-11 22:03 
GeneralRe: How can I retrieve handle of dropdown list box ? Pin
Code-o-mat24-Feb-11 22:06
Code-o-mat24-Feb-11 22:06 
GeneralRe: How can I retrieve handle of dropdown list box ? Pin
_Flaviu26-Feb-11 22:09
_Flaviu26-Feb-11 22:09 
QuestionDisabling Keypress on MessageBox Pin
si_6924-Feb-11 0:45
si_6924-Feb-11 0:45 
AnswerRe: Disabling Keypress on MessageBox PinPopular
Andrew Brock24-Feb-11 1:13
Andrew Brock24-Feb-11 1:13 
AnswerRe: Disabling Keypress on MessageBox Pin
David Crow24-Feb-11 2:57
David Crow24-Feb-11 2:57 
QuestionHow to Call C# DLL in VC++ win32? Pin
mathivanaan24-Feb-11 0:35
mathivanaan24-Feb-11 0:35 
AnswerRe: How to Call C# DLL in VC++ win32? Pin
Richard MacCutchan24-Feb-11 0:52
mveRichard MacCutchan24-Feb-11 0:52 
AnswerRe: How to Call C# DLL in VC++ win32? Pin
Cool_Dev24-Feb-11 1:15
Cool_Dev24-Feb-11 1:15 
AnswerRe: How to Call C# DLL in VC++ win32? Pin
Bernhard Hiller24-Feb-11 4:07
Bernhard Hiller24-Feb-11 4:07 
AnswerRe: How to Call C# DLL in VC++ win32? [modified] Pin
Rolf Kristensen24-Feb-11 10:09
Rolf Kristensen24-Feb-11 10:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.