| | |
windows and linux
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
>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 beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker list loop looping loops map math memory multiple news node number numbertoword output parameter pointer problem program programming project python random read recursion recursive reference rpg sorting string strings struct temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






