real_parser

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

real_parser

Bryan Spang

Hello all,

 

I am using the real_parser, but the parser is crashing for large (floating-point overflow) numbers that are entered.  For instance, if I am using the real_parser for a double precision number, and a value is entered such as 2e308, then the parsing crashes.  What is the appropriate way to use the real_parser so it can gracefully handle overflow conditions?  Thanks for any help you can provide!

 

Bryan

 

Reply | Threaded
Open this post in threaded view
|

Re: real_parser

Joel de Guzman-2
Bryan Spang wrote:

> I am using the real_parser, but the parser is crashing for large
> (floating-point overflow) numbers that are entered.  For instance, if I
> am using the real_parser for a double precision number, and a value is
> entered such as 2e308, then the parsing crashes.  What is the
> appropriate way to use the real_parser so it can gracefully handle
> overflow conditions?  Thanks for any help you can provide!

Really? That should not happen. Could you give us
a minimal compilable code that exhibits the problem?
I tried this in the numerics test. This does not crash:

assert(parse("2e308", real_p).full);

I tried both VC7.1 and GCC 3.4 and Comeau 4.3.3

Regards,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general
Reply | Threaded
Open this post in threaded view
|

RE: Re: real_parser

Bryan Spang
In reply to this post by Bryan Spang
Hi Joel,

In the template struct real_parser_impl, look at the following code:

          //  We got the exponent prefix. Now we will try to parse the
          //  actual exponent. It is an error if it is not there.
          if (RT e_n_hit = RealPoliciesT::parse_exp_n(scan))
          {
             n *= BOOST_SPIRIT_IMPL_STD_NS::
                  pow(T(10), T(e_n_hit.value()));
             count += e_n_hit.length() + e_hit.length();
          }

If the results of the n *= ... computation exceeds MAX_DBL (for double
precision numbers), then a floating point overflow exception would be
raised.  Try also, 2000e306.

Thanks!

Bryan

> I am using the real_parser, but the parser is crashing for large
> (floating-point overflow) numbers that are entered.  For instance, if
I
> am using the real_parser for a double precision number, and a value is

> entered such as 2e308, then the parsing crashes.  What is the
> appropriate way to use the real_parser so it can gracefully handle
> overflow conditions?  Thanks for any help you can provide!

Really? That should not happen. Could you give us
a minimal compilable code that exhibits the problem?
I tried this in the numerics test. This does not crash:

assert(parse("2e308", real_p).full);

I tried both VC7.1 and GCC 3.4 and Comeau 4.3.3

Regards,
--
Joel de Guzman
http://www.boost-consulting.com
http://spirit.sf.net



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server.
Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Spirit-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/spirit-general