Thread: float()
View Single Post
  #10  
Old 08-17-2010, 07:05 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xXziroXx View Post
Definitely. Just because a string STARTS with numbers doesn't mean it's a number.
This is intentional since it allows extra notation to be correctly parsed:
PHP Code:
echo(float("1.0e4")); // 10000
echo(float("0xBC"));  // 188 
GScript is behaving in this case completely as expected, and this is the same as in JavaScript and a lot of other dynamically/variantly typed languages, so no, it can't be changed without breaking it's intended functionality.

If this is a problem then you should validate your input before processing.
__________________
Skyld
Reply With Quote