Connecting Tech Pros Worldwide Help | Site Map

Invalid suffix to floating constant

skg@fluent.co.in
Guest
 
Posts: n/a
#1: Jul 23 '05
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


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Edernity
Guest
 
Posts: n/a
#2: Jul 23 '05

re: Invalid suffix to floating constant


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

skg@fluent.co.in wrote:[color=blue]
> 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.[/color]

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
wittempj@hotmail.com
Guest
 
Posts: n/a
#3: Jul 23 '05

re: Invalid suffix to floating constant


in scientific notation you set the dot before the 'e' e.g 1.23456e5 =
123456


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Rolf Magnus
Guest
 
Posts: n/a
#4: Jul 23 '05

re: Invalid suffix to floating constant


skg@fluent.co.in wrote:
[color=blue]
> 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.[/color]

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


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Kurt Stutsman
Guest
 
Posts: n/a
#5: Jul 23 '05

re: Invalid suffix to floating constant


Rolf Magnus wrote:[color=blue]
> skg@fluent.co.in wrote:
>
>[color=green]
>>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.[/color]
>
>
> You can't have fractional exponents. Maybe you meant 1234.6e5 instead?[/color]
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);

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Mark Van Peteghem
Guest
 
Posts: n/a
#6: Jul 23 '05

re: Invalid suffix to floating constant


skg@fluent.co.in wrote:
[color=blue]
>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.
>
>[/color]
It should be 1234.6e5
You can't have a dot in the exponent.

--
Mark dot Van dot Peteghem at q-mentum dot com
http://www.q-mentum.com -- easier and more powerful unit testing

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Ben Hutchings
Guest
 
Posts: n/a
#7: Jul 23 '05

re: Invalid suffix to floating constant


skg@fluent.co.in wrote:[color=blue]
> 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)[/color]

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.
[color=blue]
> 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.[/color]

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>).

--
Ben Hutchings
Having problems with C++ templates? Your questions may be answered by
<http://womble.decadentplace.org.uk/c++/template-faq.html>.

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
ThosRTanner
Guest
 
Posts: n/a
#8: Jul 23 '05

re: Invalid suffix to floating constant


Don't you mean 1234.5e6?


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Closed Thread