Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Rounding float to nearest 1000 (fixed)
//clang 3.8.0 #include <iostream> #include <cmath> using namespace std; int main() { float price; cin >> price; int roundedPrice = int(price); int multiple = 1000; roundedPrice = ((roundedPrice + multiple/2) / multiple) * multiple; cout << "Old price was: " << price << '\n'; cout << "New price is: " << roundedPrice; }
run
|
edit
|
history
|
help
0
isnan_constexpr
Standard Template Library
What's the problem with this?
Dequeue Array-Based Example
marquee text in C++
Clang-IsBaseOf
wasm test for node
Random values and probability distribution
projecte1
Virtual Function Example