Float... expertise appreciated!

Can someone please explain the concept of "float?"
I read this:
http://www.cplusplus.com/reference/cfloat/

would like to know more...

my code works... i am just curious about what float is? the homework states,
"although the individual values are integers, the results are floating- point values." can someone explain the "inbetween" process a little more, please?
i put the command in bold that is in question...


code is below:

//Write an interactive program that computes and outputs the mean and standard deviation of a set of four integer values that are input by the user

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main ()
{
// Declare your integers.
int numone;
int numtwo;
int numthree;
int numfour;
int n=4;

cout << "Please type four integer values, pressing the Enter key when complete:" << endl;
cin >> numone >> numtwo >> numthree >> numfour;

// results in floating-point values
float mean, standev;

//calc. the mean
mean= (numone + numtwo + numthree + numfour) / (n * 1);


//calc. the standard deviation
standev= pow ((numone-mean), 2) + pow ((numtwo-mean), 2);

standev= standev/(n-1);
standev= sqrt(standev);

// console display of mean and standard dev.
cout << "The mean of the four values is:" << mean << endl;

cout << "The standard deviation of the set is:" << standev << endl;

cin.get();
cin.get();
return 0 ;

}
Last edited on
A float is exactly what it says on the tin, a floating point number.

What does this mean exactly?

Imagine an integer, the number 255, in binary this is represented as 11111111 <- 1 Byte.

In binary arithmetic, the idea of a decimal space is absurd, each transmission line represents an on or off, a 0 or a 1. Even negative numbers are outlandish, the way we decipher a number is how we perceive it. For instance, we know a number is negative, if the hardware treats numbers as "signed". Usually the left most significant bit represents whether it is negative or positive

I can't exactly help you with how the geniuses who make computer chips determine floating point numbers, but for clarities sake, imagine a floating point value as using the most significant 4 bits to represent the "whole" number, and the least significant bits as the "decimal" number, so with our example:

11111111 = 15.15 = 1111.1111

This example is extremely crude (It's 5 to 4 in the morning) so I strongly urge you to research it on google.
actually, you helped me understand it a little bit more, along with google. thank you.
I am glad I could help, good luck with your studies, friend.
Topic archived. No new replies allowed.