|
-
Sep 8th, 2001, 11:58 AM
#1
Thread Starter
Fanatic Member
Scientific numbers
Code:
double var = 4894000000;
cout<<var;
This outputs 4.894e+009 for the value. How can I have it output 4894000000 instead?
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 8th, 2001, 01:19 PM
#2
Frenzied Member
I guess you could break the number up into smaller number such as 48940 and 00000 then you won't get the errors and in a console you can't tell the difference
-
Sep 8th, 2001, 02:07 PM
#3
Thread Starter
Fanatic Member
So there's no other way to do it?
Alcohol & calculus don't mix.
Never drink & derive.
-
Sep 8th, 2001, 02:42 PM
#4
Monday Morning Lunatic
Try something like cout << setwidth(20) << dValue << endl;
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 8th, 2001, 05:34 PM
#5
Heresy:
You CAN use stdio in console mode programs.
PHP Code:
#include <stdio.h>
printf( "my big number = %f\n", var);
or
char t[80];
sprinf(t,"%f",var);
printf("%s\n",t);
or (non-ansi)
Cstring str;
str.format("%f",var);
cout << str;
cout is not ansi c. C++ supports ansi c, almost mostly.
-
Sep 8th, 2001, 05:37 PM
#6
Monday Morning Lunatic
The reason cout isn't ANSI C is because it's ANSI C++ 
You can use stdio, but there's no point if you're using iostreams, which you should be in C++ programs.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|