You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Example 2.1: Computing an approximation to \pi with a Monte Carlo
400
+
method.
401
+
312
402
---------- Footnotes ----------
313
403
314
404
(1) IEEE Standard for Floating-Point Arithmetic. IEEE STD 754-2008.
315
405
IEEE Computer Society, 2008.
316
406
407
+
(2) See Section 6.4.4.2 of ISO/IEC 9899:1999.
408
+
317
409
318
410
File: fpnglib.info, Node: Generating a random float with some properties, Prev: Generating Random Floating-Point Numbers, Up: An Introduction to FPNGlib
319
411
@@ -368,10 +460,10 @@ precision.
368
460
369
461
int main(void)
370
462
{
371
-
printf("Single precision exponent in [%d, %d]\n",
372
-
fpngl_emin32,fpngl_emax32);
373
-
printf("Double precision exponent in [%d, %d]\n",
374
-
fpngl_emin64,fpngl_emax64);
463
+
printf("Single precision exponent in [%d, %d]\n",
464
+
fpngl_emin32,fpngl_emax32);
465
+
printf("Double precision exponent in [%d, %d]\n",
466
+
fpngl_emin64,fpngl_emax64);
375
467
}
376
468
377
469
*Output:*
@@ -392,10 +484,10 @@ precision.
392
484
393
485
int main(void)
394
486
{
395
-
printf("Number of digits with single precision: %u\n",
396
-
(uint32_t)trunc(fpngl_t32*log10(2)));
397
-
printf("Number of digits with double precision: %u\n",
398
-
(uint32_t)trunc(fpngl_t64*log10(2)));
487
+
printf("Number of digits with single precision: %u\n",
488
+
(uint32_t)trunc(fpngl_t32*log10(2)));
489
+
printf("Number of digits with double precision: %u\n",
490
+
(uint32_t)trunc(fpngl_t64*log10(2)));
399
491
}
400
492
401
493
*Output:*
@@ -413,6 +505,30 @@ easy to extend.
413
505
414
506
figure 7.1: The "classes" of FPNGlib
415
507
508
+
7.1 Debugging facilities
509
+
========================
510
+
511
+
FPNGlib offers facilities to debug itself. There are in particular some
512
+
macros that can be used to display messages to the standard error ouput
513
+
'stderr', provided the library was configured with the option
514
+
'--enable-debug=yes' (the default).
515
+
516
+
-- Macro: FPNGL_DEBUG ...
517
+
Uses 'fprintf' to output its arguments to 'stderr' if the macro
518
+
'NDEBUG' is defined to '1'. Otherwise, it does nothing.
519
+
520
+
The macro flushes the output buffer with 'fflush' after each call.
521
+
522
+
Example:
523
+
// doc/snippets/debug.c
524
+
#include <fpnglib/debug.h>
525
+
526
+
int main(void)
527
+
{
528
+
double a = 1.0;
529
+
FPNGL_DEBUG("This will be displayed only in debug mode: %g\n",a);
530
+
}
531
+
416
532
8 Concept Index
417
533
***************
418
534
@@ -435,6 +551,12 @@ figure 7.1: The "classes" of FPNGlib