2024-01-31から1日間の記事一覧
%の式だとエラーになる double a = 5.5; double b = 2.2; double remainder = fmod(a, b);
#include <iostream> #include <iomanip> #include <sstream> std::string doubleToStr(double value) { std::ostringstream oss; if (fmod(value, 1.0) == 0.0) { // 小数点以下が0の場合、整数として出力 oss << std::fixed << int(value); } else { // 小数点以下がある場合、小数点を</sstream></iomanip></iostream>…