| | |
windows and linux
![]() |
>how to create a program that has portability to work in both platforms, windows and linux.
Write 100% standard C++, or conditionally compile two different programs customized for the two operating systems.
>which function we use to round a double to the nearest int number?
You'll need to write it yourself, or use a clever workaround. Alternatively, if all you need is to print the rounded double, any formatted output option will do it for you (which opens up ideas for those clever workarounds I was talking about).
Write 100% standard C++, or conditionally compile two different programs customized for the two operating systems.
>which function we use to round a double to the nearest int number?
You'll need to write it yourself, or use a clever workaround. Alternatively, if all you need is to print the rounded double, any formatted output option will do it for you (which opens up ideas for those clever workarounds I was talking about).
I'm here to prove you wrong.
•
•
•
•
Originally Posted by Narue
Alternatively, if all you need is to print the rounded double, any formatted output option will do it for you (which opens up ideas for those clever workarounds I was talking about).
All my posts may be redistributed under the GNU Free Documentation License.
•
•
Join Date: Mar 2006
Posts: 78
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Narue
>Write 100% standard C++, or conditionally compile two different programs customized for the two operating systems.
•
•
•
•
Originally Posted by Narue
>You'll need to write it yourself, or use a clever workaround. Alternatively, if all you need is to print the rounded double, any formatted output option will do it for you (which opens up ideas for those clever workarounds I was talking about).
C++ Syntax (Toggle Plain Text)
double dAUX; int iOUT; ... if ( (floor(dAUX) - dAUX) < (ceil(dAUX) - dAUX) ) iOUT = floor(dAUX); else iOUT = ceil(dAUX);
no?
Not bad, but where you say
Personally, I prefer
(floor(dAUX) - dAUX) < (ceil(dAUX) - dAUX), I think you mean (dAUX - floor(dAUX)) < (ceil(dAUX) - dAUX).Personally, I prefer
floor(dAUX + 0.5), if I want to always round .5s in the positive direction. All my posts may be redistributed under the GNU Free Documentation License.
•
•
Join Date: Mar 2006
Posts: 78
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Rashakil Fol
Not bad, but where you say(floor(dAUX) - dAUX) < (ceil(dAUX) - dAUX), I think you mean(dAUX - floor(dAUX)) < (ceil(dAUX) - dAUX).
fabs(floor(dAUX) - dAUX)) < fabs(ceil(dAUX) - dAUX)•
•
•
•
Originally Posted by Rashakil Fol
Personally, I prefer floor(dAUX + 0.5), if I want to always round .5s in the positive direction.
![]() |
Similar Threads
- What's better? Windows 2000 Server or Linux Server? (Windows Servers and IIS)
- Windows vs. Linux (IT Professionals' Lounge)
- Do all programs in Windows XP compactible in Linux? (Getting Started and Choosing a Distro)
- Windows vs Linux (IT Professionals' Lounge)
Other Threads in the C++ Forum
- Previous Thread: hiii all
- Next Thread: Starting C++ With Knoppix
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code codesamplerunwhilecommands coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error faq file forms fstream function functions game givemetehcodez graph guess gui hash homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators infinite input int integer java lib linkedlist linker listing loop looping loops map math matrix memory multiple news node output pointer port problem proficiency program programming project python random read recursion reference rpg string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






