Why not just do this
int sign = i<=0 ? -1 : 1;
More Related Contents:
- Why do I keep getting an "expected expression error" in my While Loop? [closed]
- push_back an object into vector
- How to construct a c++ fstream from a POSIX file descriptor?
- determine size of array if passed to function
- Executing cv::warpPerspective for a fake deskewing on a set of cv::Point
- Atomicity on x86
- Is there a formula to determine overall color given BGR values? (OpenCV and C++)
- How can I declare a member vector of the same class?
- Using std::array with initialization lists
- C++ sizeof Vector is 24?
- How to avoid “if” chains?
- Number of days between two dates C++
- How to connect mySQL database using C++
- Pointer-to-pointer dynamic two-dimensional array
- how portable is end iterator decrement?
- What is the meaning of clang’s -Wweak-vtables?
- Creating a counter that stays synchronized across MPI processes
- How do I compile for Windows XP with Visual Studio 2012?
- Sell me const-correctness
- Inverting a 4×4 matrix
- sizeof(struct) returns unexpected value
- array decay to pointer and overload resolution
- stoi and std::to_string on mingw 4.7.1 [duplicate]
- Do C++ enums Start at 0?
- How to call function after window is shown?
- Debug and Release Library Linking with CMAKE (VISUAL STUDIO)
- Getting another process command line in Windows
- New (std::nothrow) vs. New within a try/catch block
- What’s the motivation behind having copy and direct initialization behave differently?
- Is a Linked-List implementation without using pointers possible or not?