Cast the operands to floats:
float ans = (float)a / (float)b;
More Related Contents:
- How do I print a double value with full precision using cout?
- Why does dividing two int not yield the right value when assigned to double?
- What is the difference between float and double?
- Double precision – decimal places
- C++ floating point precision [duplicate]
- In which order should floats be added to get the most precise result?
- Are all integer values perfectly represented as doubles? [duplicate]
- Emulate “double” using 2 “float”s
- How to ‘cout’ the correct number of decimal places of a double value?
- What is the precision of long double in C++?
- Issue when scheduling tasks using clock() function
- Set back default floating point print precision in C++
- What is the purpose of max_digits10 and how is it different from digits10?
- Matlab vs C++ Double Precision
- Is there a functional difference between “2.00” and “2.00f”?
- Exact decimal datatype for C++?
- Show two digits after decimal point in c++ [duplicate]
- Invalid operands to binary expression while implementing vector [closed]
- Why is GCC saying multiple definitions of main? I have one main [closed]
- Runtime error happens when deleting a node of the linklist [closed]
- Downcasting using the ‘static_cast’ in C++
- std::vector, default construction, C++11 and breaking changes
- do {…} while(false)
- How can I add and subtract 128 bit integers in C or C++ if my compiler does not support them?
- C++: Can a macro expand “abc” into ‘a’, ‘b’, ‘c’?
- “relocation R_X86_64_32S against ” linking Error
- Must the int main() function return a value in all compilers? [duplicate]
- std::forward_list and std::forward_list::push_back
- How to determine programmatically if an expression is rvalue or lvalue in C++?
- How can I cin and cout some unicode text?