#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# how do you output a double without exponents?

Member Posts: 1
How do you output a simple calculation (below) without the result being displayed as number * 10 to the power of x?

eg:
//-- begin code
double x = 12345;
x *= 123;

cout << x;
//-- end code

This snippet of code outputs to the console the answer "1.51844e+06", how do i make it display that answer in an expanded form ie. "1518435"???

• Member Posts: 1,202
This is the closest I know how to do:
[code]
#include

int main(void) {
double x = 12345.0 * 123.0;

std::cout.setf(std::ios_base::fixed);
std::cout << x << std::endl;

return 0;
}
[/code]
But I don't know how to clip the trailing zeroes. Tested in GCC 3.0.4.
• Member Posts: 636
: This is the closest I know how to do:
: But I don't know how to clip the trailing zeroes. Tested in GCC 3.0.4.
[code]
#include
using std::cout;
using std::endl;
using std::ios;
#include
using std::setiosflags;
using std::setprecision;

int main(){
double x = 12345.0 * 123.0;

cout << setiosflags(ios::fixed) << setprecision(0) << x << endl;

return 0;
}[/code]

• USAMember Posts: 0

_________ // http://forcoder.org // free video tutorials and ebooks about || Visual Basic .NET Delphi JavaScript Scratch Ruby PHP PL/SQL Assembly R C++ Visual Basic C Swift MATLAB Python Perl Go C# Objective-C Java Dart ABAP Crystal Scheme Bash Clojure Fortran ML Awk FoxPro Erlang Julia Ada LabVIEW SAS Prolog D Logo Lua F# Kotlin Apex Transact-SQL Alice VBScript Scala Hack Lisp Rust COBOL || ____