Invalid suffix to floating constant

S

skg

Hi,
I'm writing a c++ code, where in i'm passing a double value to a
function.
What i'm sending is a double value in scientific mode

say
set_value (1234e5.6)

G++ compiler cribs about invalid suffix .6 to floating constant.

I'm using g++-3.4.2

If i'm doing wrong, then what is the correct way of sending double
value in scientific mode.

Thanks,
Surya
 
E

Edernity

yeah, what is the . 6
if you want to send 1234000 use
set_value(1.234e6) or such
Edernity
 
R

Rolf Magnus

Hi,
I'm writing a c++ code, where in i'm passing a double value to a
function.
What i'm sending is a double value in scientific mode

say
set_value (1234e5.6)

G++ compiler cribs about invalid suffix .6 to floating constant.

You can't have fractional exponents. Maybe you meant 1234.6e5 instead?
 
K

Kurt Stutsman

Rolf said:
You can't have fractional exponents. Maybe you meant 1234.6e5 instead?
However if you really want 1234**5.6, you can do it by realizing that the
value is the same as 1234 * 10**5.6. So you could do 1234 * pow(10, 5.6);
 
B

Ben Hutchings

Hi,
I'm writing a c++ code, where in i'm passing a double value to a
function.
What i'm sending is a double value in scientific mode

say
set_value (1234e5.6)

What is that supposed to mean?

If you mean 1234 * 10 ^ 5.6, you can't write that as a literal;
you will have to use 1234.0 * pow(10.0, 5.6).

If you mean 1234.6 * 10 ^ 5, write 1234.6e5.
G++ compiler cribs about invalid suffix .6 to floating constant.

I'm using g++-3.4.2

If i'm doing wrong, then what is the correct way of sending double
value in scientific mode.

Any of the following forms:

digit+ '.' digit* [('e' | 'E') [sign] digit+]
digit+ ('e' | 'E') [sign] digit+
'.' digit+ [('e' | 'E') [sign] digit+]

(these are written using EBNF <http://en.wikipedia.org/wiki/EBNF>).
 
M

Mark Van Peteghem

Hi,
I'm writing a c++ code, where in i'm passing a double value to a
function.
What i'm sending is a double value in scientific mode

say
set_value (1234e5.6)

G++ compiler cribs about invalid suffix .6 to floating constant.
It should be 1234.6e5
You can't have a dot in the exponent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,055
Members
47,659
Latest member
salragu

Latest Threads

Top