File: conversion.qbk

package info (click to toggle)
boost1.74 1.74.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 464,084 kB
  • sloc: cpp: 3,338,324; xml: 131,293; python: 33,088; ansic: 14,336; asm: 4,034; sh: 3,351; makefile: 1,193; perl: 1,036; yacc: 478; php: 212; ruby: 102; lisp: 24; sql: 13; csh: 6
file content (161 lines) | stat: -rw-r--r-- 5,794 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
[library Boost.NumericConversion
    [quickbook 1.4]
    [authors [Cacciola Carballal, Fernando Luis]]
    [copyright 2004-2007 Fernando Luis Cacciola Carballal]
    [category numerics]
    [id numeric_conversion]
    [dirname numeric_conversion]
    [purpose
        Optimized Policy-based Numeric Conversions
    ]
    [source-mode c++]
    [license
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
[@http://www.boost.org/LICENSE_1_0.txt])
    ]
]

[/ Macros will be used for links so we have a central place to change them ]


[/ Cited Boost resources ]

[def __MPL_INTEGRAL_CONSTANT__ [@../../../../mpl/doc/refmanual/integral-constant.html MPL's Integral Constant] ]



[/ Other web resources ]

[def __SGI_UNARY_FUNCTION__ [@http://www.sgi.com/tech/stl/UnaryFunction.html Unary Function Object]]

[/ Icons ]

[def __NOTE__ [$images/note.png]]
[def __ALERT__ [$images/caution.png]]
[def __DETAIL__ [$images/note.png]]
[def __TIP__ [$images/tip.png]]
[def __QUESTION_MARK__ [$images/question.png]]
[def __SPACE__ [$images/space.png]]
[def __GO_TO__ [$images/callouts/R.png]]




[section Overview]

The Boost Numeric Conversion library is a collection of tools to describe and
perform conversions between values of different 
[link boost_numericconversion.definitions.numeric_types numeric types].

The library includes a special alternative for a subset of `std::numeric_limits<>`,
the [link boost_numericconversion.bounds___traits_class bounds<>] traits class, which provides 
a consistent way to obtain the [link boost_numericconversion.definitions.range_and_precision boundary] 
values for the [link boost_numericconversion.definitions.range_and_precision range] of a numeric type.

It also includes a set of [link boost_numericconversion.conversion_traits___traits_class trait classes] 
which describes the compile-time
properties of a conversion from a source to a target numeric type.
Both [link boost_numericconversion.definitions.c___arithmetic_types arithmetic] and 
[link boost_numericconversion.definitions.numeric_types user-defined numeric types] can be used.

A policy-based [link boost_numericconversion.converter___function_object converter] object which 
uses `conversion_traits` to select
an optimized implementation is supplied. Such implementation uses an optimal
range checking code suitable for the source/target combination.

* The converter's out-of-range behavior can be customized via an
[link boost_numericconversion.numeric_converter_policy_classes.policy_overflowhandler OverflowHandler] policy.
* For floating-point to integral conversions, the rounding mode can be selected via the
[link boost_numericconversion.numeric_converter_policy_classes.policy_float2introunder Float2IntRounder] policy.
* A custom low-level conversion routine (for UDTs for instance) can be passed via a
[link boost_numericconversion.numeric_converter_policy_classes.policy_rawconverter RawConverter] policy.
* The optimized automatic range-checking logic can be overridden via a
[link boost_numericconversion.numeric_converter_policy_classes.policy_userrangechecker UserRangeChecker] policy.

[endsect]



[include definitions.qbk]
[include converter.qbk]
[include requirements.qbk]
[include bounds.qbk]
[include conversion_traits.qbk]
[include converter_policies.qbk]
[include numeric_cast.qbk]



[section History and Acknowledgments]


[heading Pre-formal review]

* Kevlin Henney, with help from David Abrahams and Beman Dawes, originally contributed
the previous version of `numeric_cast<>` which already presented the idea of a runtime
range check.

* Later, Eric Ford, Kevin Lynch and the author spotted some genericity problems with
that `numeric_cast<>` which prevented it from being used in a generic layer of math
functions.

* An improved `numeric_cast<>` which properly handled all combinations of arithmetic
types was presented.

* David Abrahams and Beman Dawes acknowledged the need of an improved version of
`numeric_cast<>` and supported the submission as originally laid out. Daryl Walker and
Darin Adler made some important comments and proposed fixes to the original submission.

* Special thanks go to Björn Karlsoon who helped the author considerably. Having found the
problems with `numeric_cast<>` himself, he revised very carefully the original submission
and spot a subtle bug in the range checking implementation. He also wrote part of
this documentation and proof-read and corrected other parts. And most importantly:
the features now presented here in this library evolved from the original submission as
a result of the useful private communications between Björn and the author.

[heading Post-formal review]

* Guillaume Melquiond spoted some documentation and code issues, particularly about
rounding conversions.

* The following people contributed an important review of the design, documentation and c
ode: Kevin Lynch, Thorsten Ottosen, Paul Bristow, Daryle Walker, Jhon Torjo, Eric Ford,
Gennadiy Rozental.


[endsect]

[section Bibliography]

* Standard Documents: 
    # ISO/IEC 14882:98 (C++98 Standard)
    # ISO/IEC 9899:1999 (C99 Standard)
    # ISO/IEC 10967-1 (Language Independent Arithmetic (LIA), Part I, 1994)
    # ISO/IEC 2382-1:1993 (Information Technology - Vocabulary - Part I: Fundamental Terms)
    # ANSI/IEEE 754-1985 [and IEC 60559:1989] (Binary floating-point)
    # ANSI/IEEE 854-1988 (Radix Independent floating-point)
    # ANSI X3/TR-1-82 (Dictionary for Information Processing Systems)
    # ISO/IEC JTC1/SC22/WG14/N753 C9X Revision Proposal: LIA-1 Binding: Rationale
* Papers:
    # David Goldberg  What Every Computer Scientist Should Know About Floating-Point Arithmetic
    # Prof. William Kahan papers on floating-point.

[endsect]