For information on converting strings to float , see String conversion to numbers . For values of other types, the conversion is performed by converting the value to integer first and then to float.
Why it is needed to convert into integer type first, and then into float type?
Only a string could feasibly contain a float-like value. Or what is the floating point value of an array()
? Or of a resource
? As such, the rules for converting to int
are applied to such values, because those rules already exist and are defined. No need to repeat those conversion rules for all types for floats; simply apply int
rules and then cast to float
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.