Boost logo

Boost Users :

Subject: Re: [Boost-users] [lexical_cast] Canonical representation for numbers?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-09-20 15:46:55


On Monday, September 20, 2010, Francesco Biscani <bluescarni_at_[hidden]> wrote:
> Hello,
>
> does lexical_cast make some kind of guarantees on the output of
> arithmetic types cast as strings?
>
> I'm asking because I need to pass a lexical representation of integers
> and floats to the constructors of some 3rd party class that expects as
> input strings containing a certain representation of numbers. E.g., a
> float represented as string must be either in decimal or scientific
> notation, with "." as separator, "e" or "E" preceding the exponent,
> leading sign only in case of negative numbers and so on.
>
> So far I've used successfully lexical_cast for such purposes, but I'm
> wondering if other factors (e.g., locale) could alter the string
> representation of numbers. Is it safe to assume all numbers will
> always be cast in the same string structure regardless of platform,
> i18n, etc.?
>
> Cheers,
>
>  Francesco.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

you might want to look at Boost.Format. This gives you precise control
over exact format.

HTH

- Rob.

-- 
ACCU - Professionalism in programming - http://www.accu.org

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net