Numbers

I l @ ve RuBoard

Numbers

I've combined the two types of numbers ”integers and floating-point ”into one group for ease of learning. I'll discuss the difference between the two briefly .

The first type of numbers ”integers ”are the same thing as whole numbers. They can be positive or negative but include neither fractions nor decimals. Numbers which use a decimal point (even such as "1.0") are floating-point numbers. You must also use floating-point numbers to refer to fractions, since the only way to express a fraction within PHP is to convert it to its decimal equivalent. So "1 1/4" would be written as "1.25".

Examples of valid integer values include:

 1 1972 -1 

Examples of valid floating-point values include:

 1.0 19.72 -1.0 

Since we will refer to both as numbers here, any of the above would be considered valid number values.

Examples of invalid number values would include:

 1 1/4 1972a 02.23.72 

The fraction is invalid as it contains two unusable characters : the space and the slash (/). The second item is invalid as it uses both numbers and letters , which is acceptable for the name of a variable, but not as the value of a number variable. The third example is invalid since it uses two decimal points. If you need to refer to one of these values for some reason other than to perform calculations on them, you can assign them as strings.

I l @ ve RuBoard


PHP for the World Wide Web (Visual QuickStart Guide)
PHP for the World Wide Web (Visual QuickStart Guide)
ISBN: 0201727870
EAN: 2147483647
Year: 2001
Pages: 116
Authors: Larry Ullman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net