9. (Machine Precision Issues) This exercise requires that you do some research into how C++11 and Boost

Question:

9. (Machine Precision Issues)

This exercise requires that you do some research into how C++11 and Boost C++

Math Toolkit support the following functionality (x is a given value):

 The next representable value that is greater than x. An overflow_error is thrown if no such value exists (float_next).

 The next representable value that is less than x. An overflow_error is thrown if no such value exists (float_prior).

 Advance a floating-point number by a specified number of ULPs (Units in Last Place)

(float_advance).

 Find the number of gaps/bits/ULPs between two floating-point values (float_ distance).

 (C++11 and Boost) Return the next representable value of x in the direction y

(std/boost::nextafter(x,y)).

The Boost header file to include is:

#include

Take some specific values and experiment with these functions. Some examples are:

// Number gaps/bits/ULP between 2 floating-point values a and b

// Returns a signed value indicating whether a < b double a = 0.1;

double b = a + std::numeric_limits::min();

std::cout << boost::math::float_distance

(a,

b) << std::endl;

a = 1.0; b = 0.0;

std::cout << boost::math::float_distance

(a,

b) << std::endl;

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: