summaryrefslogtreecommitdiff
path: root/libs/math/doc/html/math_toolkit/error_handling.html
blob: eefe39045a7490b26c6c2369e2679340e0aad2ab (plain)
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Error Handling</title>
<link rel="stylesheet" href="../math.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="../index.html" title="Math Toolkit 2.1.0">
<link rel="up" href="../overview.html" title="Chapter&#160;1.&#160;Overview">
<link rel="prev" href="result_type.html" title="Calculation of the Type of the Result">
<link rel="next" href="compilers_overview.html" title="Compilers">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="result_type.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compilers_overview.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="math_toolkit.error_handling"></a><a class="link" href="error_handling.html" title="Error Handling">Error Handling</a>
</h2></div></div></div>
<h4>
<a name="math_toolkit.error_handling.h0"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.quick_reference"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.quick_reference">Quick
      Reference</a>
    </h4>
<p>
      Handling of errors by this library is split into two orthogonal parts:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          What kind of error has been raised?
        </li>
<li class="listitem">
          What should be done when the error is raised?
        </li>
</ul></div>
<div class="warning"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="../../../../../doc/src/images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>
        The default error actions are to throw an exception with an informative error
        message. If you do not try to catch the exception, you will not see the message!
      </p></td></tr>
</table></div>
<p>
      The kinds of errors that can be raised are:
    </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">Domain Error</span></dt>
<dd><p>
            Occurs when one or more arguments to a function are out of range.
          </p></dd>
<dt><span class="term">Pole Error</span></dt>
<dd><p>
            Occurs when the particular arguments cause the function to be evaluated
            at a pole with no well defined residual value. For example if <a class="link" href="sf_gamma/tgamma.html" title="Gamma">tgamma</a>
            is evaluated at exactly -2, the function approaches different limiting
            values depending upon whether you approach from just above or just below
            -2. Hence the function has no well defined value at this point and a
            Pole Error will be raised.
          </p></dd>
<dt><span class="term">Overflow Error</span></dt>
<dd><p>
            Occurs when the result is either infinite, or too large to represent
            in the numeric type being returned by the function.
          </p></dd>
<dt><span class="term">Underflow Error</span></dt>
<dd><p>
            Occurs when the result is not zero, but is too small to be represented
            by any other value in the type being returned by the function.
          </p></dd>
<dt><span class="term">Denormalisation Error</span></dt>
<dd><p>
            Occurs when the returned result would be a denormalised value.
          </p></dd>
<dt><span class="term">Rounding Error</span></dt>
<dd><p>
            Occurs when the argument to one of the rounding functions <a class="link" href="rounding/trunc.html" title="Truncation Functions">trunc</a>,
            <a class="link" href="rounding/round.html" title="Rounding Functions">round</a> and <a class="link" href="rounding/modf.html" title="Integer and Fractional Part Splitting (modf)">modf</a>
            can not be represented as an integer type, is outside the range of the
            result type.
          </p></dd>
<dt><span class="term">Evaluation Error</span></dt>
<dd><p>
            Occurs if no method of evaluation is known, or when an internal error
            occurred that prevented the result from being evaluated: this should
            never occur, but if it does, then it's likely to be due to an iterative
            method not converging fast enough.
          </p></dd>
<dt><span class="term">Indeterminate Result Error</span></dt>
<dd><p>
            Occurs when the result of a function is not defined for the values that
            were passed to it.
          </p></dd>
</dl>
</div>
<p>
      The action undertaken by each error condition is determined by the current
      <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> in effect. This can be changed program-wide
      by setting some configuration macros, or at namespace scope, or at the call
      site (by specifying a specific policy in the function call).
    </p>
<p>
      The available actions are:
    </p>
<div class="variablelist">
<p class="title"><b></b></p>
<dl class="variablelist">
<dt><span class="term">throw_on_error</span></dt>
<dd><p>
            Throws the exception most appropriate to the error condition.
          </p></dd>
<dt><span class="term">errno_on_error</span></dt>
<dd><p>
            Sets ::errno to an appropriate value, and then returns the most appropriate
            result
          </p></dd>
<dt><span class="term">ignore_error</span></dt>
<dd><p>
            Ignores the error and simply the returns the most appropriate result.
          </p></dd>
<dt><span class="term">user_error</span></dt>
<dd><p>
            Calls a <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">user-supplied
            error handler</a>.
          </p></dd>
</dl>
</div>
<p>
      The following tables show all the permutations of errors and actions, with
      the <span class="bold"><strong>default action for each error shown in bold</strong></span>:
    </p>
<div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_domain_erro"></a><p class="title"><b>Table&#160;1.1.&#160;Possible Actions for Domain Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Domain Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Throws <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code></strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">EDOM</span></code> and returns
                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">quiet_NaN</span><span class="special">()</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                Returns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">quiet_NaN</span><span class="special">()</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_domain_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_pole_errors"></a><p class="title"><b>Table&#160;1.2.&#160;Possible Actions for Pole Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Pole Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Throws <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code></strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">EDOM</span></code> and returns
                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">quiet_NaN</span><span class="special">()</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                Returns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">quiet_NaN</span><span class="special">()</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_pole_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_overflow_er"></a><p class="title"><b>Table&#160;1.3.&#160;Possible Actions for Overflow Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Overflow Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Throws <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">overflow_error</span></code></strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">ERANGE</span></code> and returns
                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">infinity</span><span class="special">()</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                Returns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">infinity</span><span class="special">()</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_overflow_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_underflow_e"></a><p class="title"><b>Table&#160;1.4.&#160;Possible Actions for Underflow Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Underflow Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                Throws <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">underflow_error</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">ERANGE</span></code> and returns
                0.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Returns 0</strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_underflow_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_denorm_erro"></a><p class="title"><b>Table&#160;1.5.&#160;Possible Actions for Denorm Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Denorm Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                Throws <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">underflow_error</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">ERANGE</span></code> and returns
                the denormalised value.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Returns the denormalised value.</strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_denorm_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_rounding_er"></a><p class="title"><b>Table&#160;1.6.&#160;Possible Actions for Rounding Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Rounding Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                Throws <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">rounding_error</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">ERANGE</span></code> and returns
                the largest representable value of the target integer type (or the
                most negative value if the argument to the function was less than
                zero).
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Returns the largest representable value of
                the target integer type (or the most negative value if the argument
                to the function was less than zero).</strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_rounding_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_internal_ev"></a><p class="title"><b>Table&#160;1.7.&#160;Possible Actions for Internal Evaluation Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Internal Evaluation Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Throws <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">evaluation_error</span></code></strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">EDOM</span></code> and returns
                the closest approximation found.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                Returns the closest approximation found.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_evaluation_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="table">
<a name="math_toolkit.error_handling.possible_actions_for_indetermina"></a><p class="title"><b>Table&#160;1.8.&#160;Possible Actions for Indeterminate Result Errors</b></p>
<div class="table-contents"><table class="table" summary="Possible Actions for Indeterminate Result Errors">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
              <p>
                Action
              </p>
            </th>
<th>
              <p>
                Behaviour
              </p>
            </th>
</tr></thead>
<tbody>
<tr>
<td>
              <p>
                throw_on_error
              </p>
            </td>
<td>
              <p>
                Throws <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">domain_error</span></code>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                errno_on_error
              </p>
            </td>
<td>
              <p>
                Sets <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>
                to <code class="computeroutput"><span class="identifier">EDOM</span></code> and returns
                the same value as <code class="computeroutput"><span class="identifier">ignore_error</span></code>.
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                ignore_error
              </p>
            </td>
<td>
              <p>
                <span class="bold"><strong>Returns a default result that depends on the
                function where the error occurred.</strong></span>
              </p>
            </td>
</tr>
<tr>
<td>
              <p>
                user_error
              </p>
            </td>
<td>
              <p>
                Returns the result of <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">user_indeterminate_result_error</span></code>:
                <a class="link" href="pol_tutorial/user_def_err_pol.html" title="Calling User Defined Error Handlers">this function
                must be defined by the user</a>.
              </p>
            </td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>
      All these error conditions are in namespace boost::math::policies, made available,
      for example, a by namespace declaration using <code class="computeroutput"><span class="keyword">namespace</span>
      <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">;</span></code> or individual using declarations <code class="computeroutput"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">overflow_error</span><span class="special">;</span></code>.
    </p>
<h4>
<a name="math_toolkit.error_handling.h1"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.rationale"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.rationale">Rationale</a>
    </h4>
<p>
      The flexibility of the current implementation should be reasonably obvious:
      the default behaviours were chosen based on feedback during the formal review
      of this library. It was felt that:
    </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
          Genuine errors should be flagged with exceptions rather than following
          C-compatible behaviour and setting <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>.
        </li>
<li class="listitem">
          Numeric underflow and denormalised results were not considered to be fatal
          errors in most cases, so it was felt that these should be ignored.
        </li>
<li class="listitem">
          If there is more than one error, only the first detected will be reported
          in the throw message.
        </li>
</ul></div>
<h4>
<a name="math_toolkit.error_handling.h2"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.finding_more_information"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.finding_more_information">Finding
      More Information</a>
    </h4>
<p>
      There are some pre-processor macro defines that can be used to <a class="link" href="pol_ref/policy_defaults.html" title="Using Macros to Change the Policy Defaults">change
      the policy defaults</a>. See also the <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">policy section</a>.
    </p>
<p>
      An example is at the Policy tutorial in <a class="link" href="pol_tutorial/changing_policy_defaults.html" title="Changing the Policy Defaults">Changing
      the Policy Defaults</a>.
    </p>
<p>
      Full source code of this typical example of passing a 'bad' argument (negative
      degrees of freedom) to Student's t distribution is <a class="link" href="stat_tut/weg/error_eg.html" title="Error Handling Example">in
      the error handling example</a>.
    </p>
<p>
      The various kind of errors are described in more detail below.
    </p>
<h4>
<a name="math_toolkit.error_handling.h3"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.domain_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.domain_error">Domain
      Errors</a>
    </h4>
<p>
      When a special function is passed an argument that is outside the range of
      values for which that function is defined, then the function returns the result
      of:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_domain_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <span class="identifier">Val</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating-point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, Val is the value that was out of
      range, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> is the current policy in use
      for the function that was called.
    </p>
<p>
      The default policy behaviour of this function is to throw a std::domain_error
      C++ exception. But if the <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> is to ignore
      the error, or set global <code class="computeroutput"><span class="special">::</span><span class="identifier">errno</span></code>,
      then a NaN will be returned.
    </p>
<p>
      This behaviour is chosen to assist compatibility with the behaviour of <span class="emphasis"><em>ISO/IEC
      9899:1999 Programming languages - C</em></span> and with the <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf" target="_top">Draft
      Technical Report on C++ Library Extensions, 2005-06-24, section 5.2.1, paragraph
      6</a>:
    </p>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="emphasis"><em>"Each of the functions declared above shall return a NaN (Not
        a Number) if any argument value is a NaN, but it shall not report a domain
        error. Otherwise, each of the functions declared above shall report a domain
        error for just those argument values for which:</em></span>
      </p></blockquote></div>
<div class="blockquote"><blockquote class="blockquote">
<p>
        <span class="emphasis"><em>"the function description's Returns clause explicitly specifies
        a domain, and those arguments fall outside the specified domain; or</em></span>
      </p>
<p>
        <span class="emphasis"><em>"the corresponding mathematical function value has a non-zero
        imaginary component; or</em></span>
      </p>
<p>
        <span class="emphasis"><em>"the corresponding mathematical function is not mathematically
        defined.</em></span>
      </p>
</blockquote></div>
<div class="blockquote"><blockquote class="blockquote"><p>
        <span class="emphasis"><em>"Note 2: A mathematical function is mathematically defined
        for a given set of argument values if it is explicitly defined for that set
        of argument values or if its limiting value exists and does not depend on
        the direction of approach."</em></span>
      </p></blockquote></div>
<p>
      Note that in order to support information-rich error messages when throwing
      exceptions, <code class="computeroutput"><span class="identifier">Message</span></code> must contain
      a <a href="../../../../format/index.html" target="_top">Boost.Format</a> recognised format
      specifier: the argument <code class="computeroutput"><span class="identifier">Val</span></code>
      is inserted into the error message according to the specifier used.
    </p>
<p>
      For example if <code class="computeroutput"><span class="identifier">Message</span></code> contains
      a "%1%" then it is replaced by the value of <code class="computeroutput"><span class="identifier">Val</span></code>
      to the full precision of T, where as "%.3g" would contain the value
      of <code class="computeroutput"><span class="identifier">Val</span></code> to 3 digits. See the
      <a href="../../../../format/index.html" target="_top">Boost.Format</a> documentation
      for more details.
    </p>
<h4>
<a name="math_toolkit.error_handling.h4"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.pole_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.pole_error">Evaluation
      at a pole</a>
    </h4>
<p>
      When a special function is passed an argument that is at a pole without a well
      defined residual value, then the function returns the result of:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_pole_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <span class="identifier">Val</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, <code class="computeroutput"><span class="identifier">Val</span></code>
      is the value of the argument that is at a pole, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a>
      is the current policy in use for the function that was called.
    </p>
<p>
      The default behaviour of this function is to throw a std::domain_error exception.
      But <a class="link" href="pol_ref/error_handling_policies.html" title="Error Handling Policies">error handling
      policies</a> can be used to change this, for example to <code class="computeroutput"><span class="identifier">ignore_error</span></code>
      and return NaN.
    </p>
<p>
      Note that in order to support information-rich error messages when throwing
      exceptions, <code class="computeroutput"><span class="identifier">Message</span></code> must contain
      a <a href="../../../../format/index.html" target="_top">Boost.Format</a> recognised format
      specifier: the argument <code class="computeroutput"><span class="identifier">val</span></code>
      is inserted into the error message according to the specifier used.
    </p>
<p>
      For example if <code class="computeroutput"><span class="identifier">Message</span></code> contains
      a "%1%" then it is replaced by the value of <code class="computeroutput"><span class="identifier">val</span></code>
      to the full precision of T, where as "%.3g" would contain the value
      of <code class="computeroutput"><span class="identifier">val</span></code> to 3 digits. See the
      <a href="../../../../format/index.html" target="_top">Boost.Format</a> documentation
      for more details.
    </p>
<h4>
<a name="math_toolkit.error_handling.h5"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.overflow_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">Numeric
      Overflow</a>
    </h4>
<p>
      When the result of a special function is too large to fit in the argument floating-point
      type, then the function returns the result of:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_overflow_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating-point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a>
      is the current policy in use for the function that was called.
    </p>
<p>
      The default policy for this function is that <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">overflow_error</span></code>
      C++ exception is thrown. But if, for example, an <code class="computeroutput"><span class="identifier">ignore_error</span></code>
      policy is used, then returns <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;::</span><span class="identifier">infinity</span><span class="special">()</span></code>.
      In this situation if the type <code class="computeroutput"><span class="identifier">T</span></code>
      doesn't support infinities, the maximum value for the type is returned.
    </p>
<h4>
<a name="math_toolkit.error_handling.h6"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.underflow_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.underflow_error">Numeric
      Underflow</a>
    </h4>
<p>
      If the result of a special function is known to be non-zero, but the calculated
      result underflows to zero, then the function returns the result of:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_underflow_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a>
      is the current policy in use for the called function.
    </p>
<p>
      The default version of this function returns zero. But with another policy,
      like <code class="computeroutput"><span class="identifier">throw_on_error</span></code>, throws
      an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">underflow_error</span></code> C++ exception.
    </p>
<h4>
<a name="math_toolkit.error_handling.h7"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.denorm_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.denorm_error">Denormalisation
      Errors</a>
    </h4>
<p>
      If the result of a special function is a denormalised value <span class="emphasis"><em>z</em></span>
      then the function returns the result of:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_denorm_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">z</span><span class="special">,</span> <span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a>
      is the current policy in use for the called function.
    </p>
<p>
      The default version of this function returns <span class="emphasis"><em>z</em></span>. But with
      another policy, like <code class="computeroutput"><span class="identifier">throw_on_error</span></code>
      throws an <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">underflow_error</span></code> C++ exception.
    </p>
<h4>
<a name="math_toolkit.error_handling.h8"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.evaluation_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.evaluation_error">Evaluation
      Errors</a>
    </h4>
<p>
      When a special function calculates a result that is known to be erroneous,
      or where the result is incalculable then it calls:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_evaluation_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <span class="identifier">Val</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, <code class="computeroutput"><span class="identifier">Val</span></code>
      is the erroneous value, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> is the current
      policy in use for the called function.
    </p>
<p>
      The default behaviour of this function is to throw a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">evaluation_error</span></code>.
    </p>
<p>
      Note that in order to support information rich error messages when throwing
      exceptions, <code class="computeroutput"><span class="identifier">Message</span></code> must contain
      a <a href="../../../../format/index.html" target="_top">Boost.Format</a> recognised format
      specifier: the argument <code class="computeroutput"><span class="identifier">val</span></code>
      is inserted into the error message according to the specifier used.
    </p>
<p>
      For example if <code class="computeroutput"><span class="identifier">Message</span></code> contains
      a "%1%" then it is replaced by the value of <code class="computeroutput"><span class="identifier">val</span></code>
      to the full precision of T, where as "%.3g" would contain the value
      of <code class="computeroutput"><span class="identifier">val</span></code> to 3 digits. See the
      <a href="../../../../format/index.html" target="_top">Boost.Format</a> documentation
      for more details.
    </p>
<h4>
<a name="math_toolkit.error_handling.h9"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.indeterminate_result_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.indeterminate_result_error">Indeterminate
      Result Errors</a>
    </h4>
<p>
      When the result of a special function is indeterminate for the value that was
      passed to it, then the function returns the result of:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_overflow_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <span class="identifier">Val</span><span class="special">,</span> <span class="identifier">Default</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating-point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, Val is the value for which the
      result is indeterminate, Default is an alternative default result that must
      be returned for <code class="computeroutput"><span class="identifier">ignore_error</span></code>
      and <code class="computeroutput"><span class="identifier">errno_on_erro</span></code> policies,
      and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> is the current policy in use for the
      function that was called.
    </p>
<p>
      The default policy for this function is <code class="computeroutput"><span class="identifier">ignore_error</span></code>:
      note that this error type is reserved for situations where the result is mathematically
      undefined or indeterminate, but there is none the less a convention for what
      the result should be: for example the C99 standard specifies that the result
      of 0<sup>0</sup> is 1, even though the result is actually mathematically indeterminate.
    </p>
<h4>
<a name="math_toolkit.error_handling.h10"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.rounding_error"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.rounding_error">Rounding
      Errors</a>
    </h4>
<p>
      When one of the rounding functions <a class="link" href="rounding/round.html" title="Rounding Functions">round</a>,
      <a class="link" href="rounding/trunc.html" title="Truncation Functions">trunc</a> or <a class="link" href="rounding/modf.html" title="Integer and Fractional Part Splitting (modf)">modf</a>
      is called with an argument that has no integer representation, or is too large
      to be represented in the result type then the value returned is the result
      of a call to:
    </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">policies</span><span class="special">::</span><span class="identifier">raise_rounding_error</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;(</span><span class="identifier">FunctionName</span><span class="special">,</span> <span class="identifier">Message</span><span class="special">,</span> <span class="identifier">Val</span><span class="special">,</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">);</span>
</pre>
<p>
      Where <code class="computeroutput"><span class="identifier">T</span></code> is the floating point
      type passed to the function, <code class="computeroutput"><span class="identifier">FunctionName</span></code>
      is the name of the function, <code class="computeroutput"><span class="identifier">Message</span></code>
      is an error message describing the problem, <code class="computeroutput"><span class="identifier">Val</span></code>
      is the erroneous argument, and <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a> is the
      current policy in use for the called function.
    </p>
<p>
      The default behaviour of this function is to throw a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">math</span><span class="special">::</span><span class="identifier">rounding_error</span></code>.
    </p>
<p>
      Note that in order to support information rich error messages when throwing
      exceptions, <code class="computeroutput"><span class="identifier">Message</span></code> must contain
      a <a href="../../../../format/index.html" target="_top">Boost.Format</a> recognised format
      specifier: the argument <code class="computeroutput"><span class="identifier">val</span></code>
      is inserted into the error message according to the specifier used.
    </p>
<p>
      For example if <code class="computeroutput"><span class="identifier">Message</span></code> contains
      a "%1%" then it is replaced by the value of <code class="computeroutput"><span class="identifier">val</span></code>
      to the full precision of T, where as "%.3g" would contain the value
      of <code class="computeroutput"><span class="identifier">val</span></code> to 3 digits. See the
      <a href="../../../../format/index.html" target="_top">Boost.Format</a> documentation
      for more details.
    </p>
<h4>
<a name="math_toolkit.error_handling.h11"></a>
      <span class="phrase"><a name="math_toolkit.error_handling.checked_narrowing_cast"></a></span><a class="link" href="error_handling.html#math_toolkit.error_handling.checked_narrowing_cast">Errors
      from typecasts</a>
    </h4>
<p>
      Many special functions evaluate their results at a higher precision than their
      arguments in order to ensure full machine precision in the result: for example,
      a function passed a float argument may evaluate its result using double precision
      internally. Many of the errors listed above may therefore occur not during
      evaluation, but when converting the result to the narrower result type. The
      function:
    </p>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">,</span> <span class="keyword">class</span> <a class="link" href="../policy.html" title="Chapter&#160;14.&#160;Policies: Controlling Precision, Error Handling etc">Policy</a><span class="special">,</span> <span class="keyword">class</span> <span class="identifier">U</span><span class="special">&gt;</span>
<span class="identifier">T</span> <span class="identifier">checked_narrowing_cast</span><span class="special">(</span><span class="identifier">U</span> <span class="keyword">const</span><span class="special">&amp;</span> <span class="identifier">val</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span><span class="special">*</span> <span class="identifier">function</span><span class="special">);</span>
</pre>
<p>
      Is used to perform these conversions, and will call the error handlers listed
      above on <a class="link" href="error_handling.html#math_toolkit.error_handling.overflow_error">overflow</a>,
      <a class="link" href="error_handling.html#math_toolkit.error_handling.underflow_error">underflow</a>
      or <a class="link" href="error_handling.html#math_toolkit.error_handling.denorm_error">denormalisation</a>.
    </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright &#169; 2006-2010, 2012-2014 Nikhar Agrawal,
      Anton Bikineev, Paul A. Bristow, Marco Guazzone, Christopher Kormanyos, Hubert
      Holin, Bruno Lalande, John Maddock, Johan R&#229;de, Gautam Sewani, Benjamin Sobotta,
      Thijs van den Berg, Daryle Walker and Xiaogang Zhang<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="result_type.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="compilers_overview.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>