dconv 2.0
C++14 library for printing and parsing floating point numbers
Loading...
Searching...
No Matches
dconv Namespace Reference

Namespaces

namespace  details
 
namespace  eisellemire
 
namespace  grisu
 
namespace  grisu2
 
namespace  grisu3
 
namespace  schubfach
 

Classes

class  DiyFp
 hand made floating point. More...
 
class  ErrorCategory
 conversion error category. More...
 
class  StreamProbe
 stream probe. More...
 
class  StringProbe
 string probe. More...
 

Enumerations

enum class  AtodMode : uint32_t { Json = 0 , ParseNanAndInf = 1L << 0 , ParseRelaxedNumber = 1L << 1 , General = ParseNanAndInf | ParseRelaxedNumber }
 string to double conversion mode. More...
 
enum class  Errc { Success = 0 , InvalidNumber , NotDouble }
 conversion error codes. More...
 

Functions

constexpr AtodMode operator& (AtodMode a, AtodMode b) noexcept
 perform binary AND on AtodMode.
 
constexpr AtodMode operator| (AtodMode a, AtodMode b) noexcept
 perform binary OR on AtodMode.
 
constexpr AtodMode operator^ (AtodMode a, AtodMode b) noexcept
 perform binary XOR on AtodMode.
 
constexpr AtodMode operator~ (AtodMode a) noexcept
 perform binary NOT on AtodMode.
 
constexpr const AtodMode & operator&= (AtodMode &a, AtodMode b) noexcept
 perform binary AND assignment on AtodMode.
 
constexpr const AtodMode & operator|= (AtodMode &a, AtodMode b) noexcept
 perform binary OR assignment on AtodMode.
 
constexpr const AtodMode & operator^= (AtodMode &a, AtodMode b) noexcept
 perform binary XOR assignment on AtodMode.
 
template<AtodMode Mode = AtodMode::General>
int atod (StreamProbe &probe, double &value, uint64_t &significand, int64_t &exponent, bool &negative, std::error_code &ec)
 stream to double conversion that stops on integers.
 
template<AtodMode Mode = AtodMode::General>
bool atod (StreamProbe &probe, double &value)
 stream to double conversion.
 
template<AtodMode Mode = AtodMode::General>
bool atod (std::istream &in, double &value)
 stream to double conversion.
 
template<AtodMode Mode = AtodMode::General>
int atod (StringProbe &probe, double &value, uint64_t &significand, int64_t &exponent, bool &negative, std::error_code &ec)
 string to double conversion that stops on integers.
 
template<AtodMode Mode = AtodMode::General>
bool atod (StringProbe &probe, double &value)
 string to double conversion.
 
template<AtodMode Mode = AtodMode::General>
const char * atod (const char *str, double &value)
 string to double conversion.
 
template<AtodMode Mode = AtodMode::General>
const char * atod (const char *str, size_t length, double &value)
 string to double conversion.
 
template<AtodMode Mode = AtodMode::General>
const char * atod (const char *first, const char *last, double &value)
 string to double conversion.
 
template<AtodMode Mode = AtodMode::General>
const char * atod (std::string_view str, double &value)
 string to double conversion.
 
template<AtodMode Mode = AtodMode::General>
const char * atod (std::string &&str, double &value)=delete
 string to double conversion from a temporary string.
 
constexpr DiyFp operator- (const DiyFp &lhs, const DiyFp &rhs)
 minus operator
 
constexpr DiyFp operator* (const DiyFp &lhs, const DiyFp &rhs)
 multiplication operator.
 
char * dtoa (char *buffer, double value) noexcept
 double to string conversion.
 
const std::error_category & errorCategory () noexcept
 get error category.
 
std::error_code make_error_code (Errc code) noexcept
 create an std::error_code object.
 
std::error_condition make_error_condition (Errc code) noexcept
 create an std::error_condition object.
 

Variables

const ErrorCategory errorCategoryInstance
 conversion error category instance.
 

Detailed Description

MIT License

Copyright (c) 2021 Mathieu Rabine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Copyright (c) 2026 Mathieu Rabine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Copyright (c) 2025 Mathieu Rabine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MIT License

Copyright (c) 2026 Mathieu Rabine

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Enumeration Type Documentation

◆ AtodMode

enum class dconv::AtodMode : uint32_t
strong

string to double conversion mode.

Enumerator
Json 

JSON number grammar.

ParseNanAndInf 

parse nan, inf and infinity.

ParseRelaxedNumber 

parse leading zeros and missing digits around the point.

General 

general format.

◆ Errc

enum class dconv::Errc
strong

conversion error codes.

Enumerator
Success 

Success.

InvalidNumber 

Number is invalid.

NotDouble 

Number is an integer.

Function Documentation

◆ atod() [1/10]

template<AtodMode Mode = AtodMode::General>
const char * dconv::atod ( const char * first,
const char * last,
double & value )
inline

string to double conversion.

Parameters
firststring first position.
laststring last position.
valueconverted value.
Returns
end position on success, nullptr on failure.

◆ atod() [2/10]

template<AtodMode Mode = AtodMode::General>
const char * dconv::atod ( const char * str,
double & value )
inline

string to double conversion.

Parameters
strstring to parse.
valueconverted value.
Returns
end position on success, nullptr on failure.

◆ atod() [3/10]

template<AtodMode Mode = AtodMode::General>
const char * dconv::atod ( const char * str,
size_t length,
double & value )
inline

string to double conversion.

Parameters
strstring to parse.
lengthstring length.
valueconverted value.
Returns
end position on success, nullptr on failure.

◆ atod() [4/10]

template<AtodMode Mode = AtodMode::General>
bool dconv::atod ( std::istream & in,
double & value )
inline

stream to double conversion.

Parameters
instream to read from.
valueconverted value.
Returns
true on success, false otherwise.

◆ atod() [5/10]

template<AtodMode Mode = AtodMode::General>
const char * dconv::atod ( std::string && str,
double & value )
delete

string to double conversion from a temporary string.

Parameters
strtemporary string.
valueconverted value.
Returns
end position on success, nullptr on failure.

◆ atod() [6/10]

template<AtodMode Mode = AtodMode::General>
const char * dconv::atod ( std::string_view str,
double & value )
inline

string to double conversion.

Parameters
strstring to parse.
valueconverted value.
Returns
end position on success, nullptr on failure.

◆ atod() [7/10]

template<AtodMode Mode = AtodMode::General>
bool dconv::atod ( StreamProbe & probe,
double & value )
inline

stream to double conversion.

Parameters
probeprobe to read from.
valueconverted value.
Returns
true on success, false otherwise.

◆ atod() [8/10]

template<AtodMode Mode = AtodMode::General>
int dconv::atod ( StreamProbe & probe,
double & value,
uint64_t & significand,
int64_t & exponent,
bool & negative,
std::error_code & ec )
inline

stream to double conversion that stops on integers.

Parameters
probeprobe to read from.
valueconverted value.
significandinteger value when the error is NotDouble, first significant digits read otherwise.
exponentdecimal exponent read.
negativesign read.
ecerror code set on failure.
Returns
0 on success, -1 on failure.

◆ atod() [9/10]

template<AtodMode Mode = AtodMode::General>
bool dconv::atod ( StringProbe & probe,
double & value )
inline

string to double conversion.

Parameters
probeprobe to read from.
valueconverted value.
Returns
true on success, false otherwise.

◆ atod() [10/10]

template<AtodMode Mode = AtodMode::General>
int dconv::atod ( StringProbe & probe,
double & value,
uint64_t & significand,
int64_t & exponent,
bool & negative,
std::error_code & ec )
inline

string to double conversion that stops on integers.

Parameters
probeprobe to read from.
valueconverted value.
significandinteger value when the error is NotDouble, first significant digits read otherwise.
exponentdecimal exponent read.
negativesign read.
ecerror code set on failure.
Returns
0 on success, -1 on failure.

◆ dtoa()

char * dconv::dtoa ( char * buffer,
double value )
inlinenoexcept

double to string conversion.

Parameters
bufferbuffer to write the string representation to (must point to at least 25 writable bytes).
valuevalue to convert.
Returns
end position.

◆ errorCategory()

const std::error_category & dconv::errorCategory ( )
inlinenoexcept

get error category.

Returns
the created std::error_category object.

◆ make_error_code()

std::error_code dconv::make_error_code ( Errc code)
inlinenoexcept

create an std::error_code object.

Parameters
codeerror code number.
Returns
the created std::error_code object.

◆ make_error_condition()

std::error_condition dconv::make_error_condition ( Errc code)
inlinenoexcept

create an std::error_condition object.

Parameters
codeerror code number.
Returns
the created std::error_condition object.

◆ operator&()

AtodMode dconv::operator& ( AtodMode a,
AtodMode b )
constexprnoexcept

perform binary AND on AtodMode.

Parameters
abitset.
bother bitset.
Returns
bitset result of binary AND on AtodMode.

◆ operator&=()

const AtodMode & dconv::operator&= ( AtodMode & a,
AtodMode b )
constexprnoexcept

perform binary AND assignment on AtodMode.

Parameters
abitset.
bother bitset.
Returns
reference to updated bitset.

◆ operator*()

DiyFp dconv::operator* ( const DiyFp & lhs,
const DiyFp & rhs )
inlineconstexpr

multiplication operator.

Parameters
lhsfloating point.
rhsfloating point.
Returns
a floating point from lhs multiplied by rhs.

◆ operator-()

DiyFp dconv::operator- ( const DiyFp & lhs,
const DiyFp & rhs )
inlineconstexpr

minus operator

Parameters
lhsfloating point.
rhsfloating point.
Returns
a floating point from lhs minus rhs.

◆ operator^()

AtodMode dconv::operator^ ( AtodMode a,
AtodMode b )
constexprnoexcept

perform binary XOR on AtodMode.

Parameters
abitset.
bother bitset.
Returns
bitset result of binary XOR on AtodMode.

◆ operator^=()

const AtodMode & dconv::operator^= ( AtodMode & a,
AtodMode b )
constexprnoexcept

perform binary XOR assignment on AtodMode.

Parameters
abitset.
bother bitset.
Returns
reference to updated bitset.

◆ operator|()

AtodMode dconv::operator| ( AtodMode a,
AtodMode b )
constexprnoexcept

perform binary OR on AtodMode.

Parameters
abitset.
bother bitset.
Returns
bitset result of binary OR on AtodMode.

◆ operator|=()

const AtodMode & dconv::operator|= ( AtodMode & a,
AtodMode b )
constexprnoexcept

perform binary OR assignment on AtodMode.

Parameters
abitset.
bother bitset.
Returns
reference to updated bitset.

◆ operator~()

AtodMode dconv::operator~ ( AtodMode a)
constexprnoexcept

perform binary NOT on AtodMode.

Parameters
abitset.
Returns
bitset result of binary NOT on AtodMode.

Variable Documentation

◆ errorCategoryInstance

const ErrorCategory dconv::errorCategoryInstance
inline

conversion error category instance.