Boost logo

Boost Users :

Subject: [Boost-users] [lexical_cast] Canonical representation for numbers?
From: Francesco Biscani (bluescarni_at_[hidden])
Date: 2010-09-20 12:56:42


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