This is because of integer division do round(1.0/length);
instead. Also use float
or double
.
More Related Contents:
- Difference between this. and this->
- Prime Numbers (C++) – Not Working 100%
- What are the basic rules and idioms for operator overloading?
- What is the copy-and-swap idiom?
- What happens if you call erase() on a map element while iterating from begin to end?
- Omitting return statement in C++
- constexpr and initialization of a static const void pointer with reinterpret cast, which compiler is right?
- Is floating-point == ever OK?
- How do I write a range pipeline that uses temporary containers?
- Does true equal to 1 and false equal to 0? [duplicate]
- std::map emplace without copying value
- QtCore.QObject.connect in a loop only affects the last instance
- Parsing Command Line Arguments in C++? [closed]
- Are parent class constructors called before initializing variables?
- OSX – replace gcc version 4.2.1 with 4.9 installed via Homebrew
- Can a cast operator be explicit?
- How do the stream manipulators work?
- Can i use nested loops with vectors in cpp?
- How to use boost preprocessor to generate accessors?
- Function clrscr in C and C++
- C++ Structure Initialization [duplicate]
- How can an incomplete type be used as a template parameter to vector here?
- c++ sizeof(array) return twice the array’s declared length
- Undefined behavior causing time travel
- When Does Move Constructor get called?
- How do I use the MinGW gdb debugger to debug a C++ program in Windows?
- Why must I put a semicolon at the end of class declaration in C++?
- sprintf for unsigned _int64
- Unable to read frames from VideoCapture from secondary webcam with OpenCV
- Getting a list of user profiles on a computer in C++ Win32