473,395 Members | 1,457 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Exponential

In this code the exponential part using scientific notation becomes
e+002 is ther a way of changging the number of values after e so they
can appear like e+02, only 2 values instead 3??

I have been thinking a lot about this!!!
any comments
// modify floatfield using manipulators
#include <iostream>
using namespace std;

int main () {
float f;
f=365.25;
cout << fixed << f << endl;
cout << scientific << f << endl;
return 0;
}

The execution of this example shall display:
365.250000
3.652500e+002

Jul 23 '05 #1
1 6768
<di**********@gmail.com> wrote...
In this code the exponential part using scientific notation becomes
e+002 is ther a way of changging the number of values after e so they
can appear like e+02, only 2 values instead 3??
There is no way using C++ manipulators only, if that's what you're
asking.

The reason is in the C library. C++ specifies that 'scientific' shall
cause the output to be the same as %e (or %E if 'uppercase' is set) in
fprintf. In C++ %e causes output of as many digits in the exponent as
necessary to represent the exponent. On your system 'double' (and that
is what your 'float' is converted to) has probably three digits of the
exponent, and that's why it prints e+002.

The only way to achieve 2 digits in your output is to perform your own
conversion to, say, a string, and then output that string.
I have been thinking a lot about this!!!
any comments
// modify floatfield using manipulators
#include <iostream>
using namespace std;

int main () {
float f;
f=365.25;
cout << fixed << f << endl;
cout << scientific << f << endl;
return 0;
}

The execution of this example shall display:
365.250000
3.652500e+002

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ryoga | last post by:
How can I print out the value of a large double in plain decimal form without the exponential notation? For example (quick code): PlainPrint.java: --------------- public class PlainPrint {...
4
by: Timothy Fitz | last post by:
Why are all numberical literals in exponential notation floats? To me it is counter-intuitive for 1e3 to behave so fundamentally different from 1000. Timothy Fitz
1
by: Mahesha | last post by:
Exponential Moving avg is calculated using the formula. EMA = (Today's Price)* K + (EMA yesterday) * (1-K) where K = 2 / (N+1) The user is going to Input the K. It is something like F(N) =...
9
by: J.Sperlhofer | last post by:
Good morning, Javascript-Professionals. I'm looking for an possibility to show a (calculated) 64bit-Number without exponential notation. I don't want to see exponational notation within my...
2
by: Rod Brick | last post by:
I'm trying to print a Double in straight decimal form, not exponential. I can't seem to accomplish this. This seems like it should be simple enough. The output I'm looking for is "0.00001", not...
8
by: Martin Jørgensen | last post by:
Hi, I have a program that reads in a couple of numbers from files and then stores them with some latex-code but I'm not satisfied with the exponential output, as it takes up too many character...
2
by: Poz | last post by:
Is there a way to convert an exponential number (held in string format) to non-exponential format without losing any precision in the number? For example, I have a string variable containing...
4
by: b4ukiran | last post by:
Hi all, I have a requirement to print large double values without the exponential notaion. The double value can be a declared variable or any calculated value within the code. In any case, I...
3
ashsa
by: ashsa | last post by:
Hi everyone, I am trying to display a numeric value fetched from an sql server table which is stored in the exponential notation. For eg, 0.08 is getting stored in the table as...
1
by: pankajprakash | last post by:
Hi, I have a decimal number. I need to convert this decimal value to exponential value. I have a vb.net code to convert from decimal to exponential value is Format(100000, #.0#E-##) . When I run this...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.