Presentation is loading. Please wait.

Presentation is loading. Please wait.

Floating Point Values Internally, floating point numbers have three pairs: a sign (positive or negative), a mantissa (has a fixed number of digits) and.

Similar presentations


Presentation on theme: "Floating Point Values Internally, floating point numbers have three pairs: a sign (positive or negative), a mantissa (has a fixed number of digits) and."— Presentation transcript:

1 Floating Point Values Internally, floating point numbers have three pairs: a sign (positive or negative), a mantissa (has a fixed number of digits) and an exponent. You can write a floating point literal in three basic forms: as a decimal value including a decimal point, for example with an exponent, for example 11E1 (or 11e1). using both a decimal point and an exponent, for example 1.1e2. Floating Point Values tMyn

2 There are three floating point data types:
float, single precision floating point values double, double precision floating point values long double, extended precision floating point values The term precision refers to the number of significant digits in the mantissa. The data types are in order of increasing precision, with float providing the lowest number of digits in the mantissa. The precision only determines the number of digits in mantissa. Floating Point Values tMyn

3 By default, floating point literals are of type double:
The range of numbers that can be represented by a particular type is determined primarly by the range of possible exponents. By default, floating point literals are of type double: double mass=64.9; Floating Point Values tMyn

4 #include <iostream> #include <limits>
#include "stdafx.h" #include <iostream> #include <limits> #include <iomanip> using namespace System; using namespace std; int main(array<System::String ^> ^args) { cout<<sizeof(float)<<" bytes."<<endl; cout<<sizeof(double)<<" bytes."<<endl; cout<<sizeof(long double)<<" bytes."<<endl; Floating Point Values tMyn

5 cout<<"The maximum type float value "
<<setprecision(20)<<FLT_MAX<<"."<<endl; cout<<"The maximum type double value " <<setprecision(20)<<DBL_MAX<<"."<<endl; cout<<"The minimun positive type float value " <<setprecision(20)<<FLT_MIN<<"."<<endl; cout<<"The minimun positive type double value " <<setprecision(20)<<DBL_MIN<<"."<<endl; return 0; } Floating Point Values tMyn

6 Floating Point Values tMyn


Download ppt "Floating Point Values Internally, floating point numbers have three pairs: a sign (positive or negative), a mantissa (has a fixed number of digits) and."

Similar presentations


Ads by Google