Click here to Skip to main content
15,908,013 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow do you round a float variable in C++ [modified] Pin
BlitzPackage29-Sep-06 18:48
BlitzPackage29-Sep-06 18:48 
AnswerRe: How do you round a float variable in C++ Pin
ShilpiP29-Sep-06 19:14
ShilpiP29-Sep-06 19:14 
GeneralRe: How do you round a float variable in C++ Pin
amaneet29-Sep-06 21:42
amaneet29-Sep-06 21:42 
GeneralRe: How do you round a float variable in C++ Pin
ShilpiP29-Sep-06 23:14
ShilpiP29-Sep-06 23:14 
GeneralRe: How do you round a float variable in C++ Pin
Stephen Hewitt30-Sep-06 2:27
Stephen Hewitt30-Sep-06 2:27 
GeneralRe: How do you round a float variable in C++ Pin
Hamid_RT2-Oct-06 9:02
Hamid_RT2-Oct-06 9:02 
AnswerRe: How do you round a float variable in C++ Pin
Eytukan30-Sep-06 7:32
Eytukan30-Sep-06 7:32 
AnswerRe: How do you round a float variable in C++ Pin
BlitzPackage30-Sep-06 10:05
BlitzPackage30-Sep-06 10:05 
First, thank you all for your answers, they are proving very helpful.

Now, however, I've encountered a different issue:

I get the right results from the floor function. However, when I do the final division (I'm getting this information from stepping through the code in the VC++ .NET Debugger):

//m_fAmount is a float
m_fAmount = 30679.000
iDivisor = 1000.0000

m_fAmount / iDivisor yields: 30.679001

I am really puzzled as I'd like to think that the compiler can do simple arithmatic Smile | :) However, in all seriousness, what's causing this, I'm really puzzled.

Any and all help is greatly appreicated.

Thanks,
BP
GeneralRe: How do you round a float variable in C++ Pin
markkuk30-Sep-06 12:52
markkuk30-Sep-06 12:52 
GeneralRe: How do you round a float variable in C++ Pin
BlitzPackage30-Sep-06 13:36
BlitzPackage30-Sep-06 13:36 
GeneralRe: How do you round a float variable in C++ Pin
Stephen Hewitt30-Sep-06 16:04
Stephen Hewitt30-Sep-06 16:04 
GeneralRe: How do you round a float variable in C++ Pin
BlitzPackage30-Sep-06 19:11
BlitzPackage30-Sep-06 19:11 
QuestionReturn an Object By Value Pin
BlitzPackage29-Sep-06 17:23
BlitzPackage29-Sep-06 17:23 
AnswerRe: Return an Object By Value Pin
Mike_V29-Sep-06 17:36
Mike_V29-Sep-06 17:36 
GeneralRe: Return an Object By Value Pin
BlitzPackage29-Sep-06 17:43
BlitzPackage29-Sep-06 17:43 
GeneralRe: Return an Object By Value Pin
Mike_V29-Sep-06 17:59
Mike_V29-Sep-06 17:59 
GeneralRe: Return an Object By Value Pin
BlitzPackage29-Sep-06 18:04
BlitzPackage29-Sep-06 18:04 
AnswerRe: Return an Object By Value Pin
Anonymuos29-Sep-06 23:01
Anonymuos29-Sep-06 23:01 
AnswerRe: Return an Object By Value Pin
bob1697230-Sep-06 5:55
bob1697230-Sep-06 5:55 
QuestionFinding Your Own Responses Back Pin
Bram van Kampen29-Sep-06 16:39
Bram van Kampen29-Sep-06 16:39 
QuestionNotification of unhecking the checkbox inside the DateTimeCtrl... Pin
tamasan29-Sep-06 16:29
tamasan29-Sep-06 16:29 
AnswerRe: Notification of unhecking the checkbox inside the DateTimeCtrl... Pin
ShilpiP29-Sep-06 19:34
ShilpiP29-Sep-06 19:34 
AnswerRe: Notification of unhecking the checkbox inside the DateTimeCtrl... Pin
Hamid_RT2-Oct-06 9:38
Hamid_RT2-Oct-06 9:38 
QuestionErrors encountered when linking Dialog based application with C code Pin
searcher0829-Sep-06 16:24
searcher0829-Sep-06 16:24 
AnswerRe: Errors encountered when linking Dialog based application with C code Pin
ShilpiP29-Sep-06 19:44
ShilpiP29-Sep-06 19:44 

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.