74Part IPHP: The BasicsNote that the fact (Msn web hosting) that

74Part IPHP: The BasicsNote that the fact that $even_doubleis a round number does not make it an integer. Integers and doubles are stored in different underlying formats, and the result of: $five = $even_double + 3; is a double, not an integer, even if it prints as 5. In almost all situations, however, you shouldfeel free to mix doubles and integers in mathematical expressions, and let PHP sort out thetyping. By default, doubles print with the minimum number of decimal places needed for example, the code: $many = 2.2888800; $many_2 = 2.2111200; $few = $many + $many_2; print( $many + $many_2 = $few
); produces the browser output: 2.28888 + 2.21112 = 4.5If you need finer control of printing, see the printffunction in Chapter 8. Read formatsThe typical read formatfor doubles is -X.Y, where the -optionally specifies a negative num- ber, and both Xand Yare sequences of digits between 0 and 9. The Xpart may be omitted ifthe number is between 1.0 and 1.0, and the Ypart can also be omitted. Leading or trailingzeros have no effect. All the following are legal doubles: $small_positive = 0.12345; $small_negative = -.12345$even_double = 2.00000; $still_double = 2.; In addition, doubles can be specified in scientific notation, by adding the letter eand adesired integral power of 10 to the end of the previous format for example, 2.2e-3wouldcorrespond to 2.2 10-3. The floating-point part of the number need not be restricted to arange between 1.0 and 10.0. All the following are legal: $small_positive = 5.5e-3; print( small_positive is $small_positive
); $large_positive = 2.8e+16; print( large_positive is $large_positive
); $small_negative = -2222e-10; print( small_negative is $small_negative
); $large_negative = -0.00189e6; print( large_negative is $large_negative
); The preceding code produces the following browser output: small_positive is 0.0055large_positive is 2.8E+16small_negative is -2.222E-07large_negative is 1890Cross- Reference07
Note: In case you are looking for affordable and reliable webhost to host and run your business application check Vision ftp web hosting services

Leave a Reply