Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-17-2010, 03:10 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
float()

Can anyone tell me if this is supposed to happen and if so, why?

PHP Code:
float(123) = 123
float
("123") = 123
float
("str") = -1
float
("str123") = -1
float
("123str") = 123 
Note the very last one. If a string starts with numbers, the float() command thinks it's a number, and I find this very annoying and misleading. If it is indeed a bug with the engine, could it be fixed please?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto

Last edited by xXziroXx; 08-17-2010 at 03:22 AM..
Reply With Quote
  #2  
Old 08-17-2010, 03:29 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
This is known behavior, and I think intentional (would need to contact Stefan for reasoning). It shouldn't be hard to make your own float function which calls the internal float only in the case where all the characters of the string are integers (or decimal points). Not sure about scientific notation and how it handles that.
Reply With Quote
  #3  
Old 08-17-2010, 03:45 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well this is just silly.

PHP Code:
echo("123str" "123str"); // echos 246 
__________________
Quote:
Reply With Quote
  #4  
Old 08-17-2010, 03:47 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by WhiteDragon View Post
This is known behavior, and I think intentional (would need to contact Stefan for reasoning). It shouldn't be hard to make your own float function which calls the internal float only in the case where all the characters of the string are integers (or decimal points). Not sure about scientific notation and how it handles that.
I'd rather have the default float() function work like the way it, at least in my opinion, is supposed to work.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 08-17-2010, 03:48 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by xXziroXx View Post
I'd rather have the default float() function work like the way it, at least in my opinion, is supposed to work.
It'd involve reworking literally all the string->number casting in GS which could introduce bugs. (Not saying that I disagree with your motive, it's just unrealistic.)
Reply With Quote
  #6  
Old 08-17-2010, 04:31 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by WhiteDragon View Post
which could introduce bugs.
More like fix current bugs and have it work like supposed too after that. Maybe Stefan could even write something up that'll only affect how float() handles things.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #7  
Old 08-17-2010, 04:34 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
int("123str") should really return -1 too
__________________
Quote:
Reply With Quote
  #8  
Old 08-17-2010, 04:36 AM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about
Quote:
Originally Posted by WhiteDragon View Post
It'd involve reworking literally all the string->number casting
This is data conversion, not casting.
__________________
Kat
Reply With Quote
  #9  
Old 08-17-2010, 04:41 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by fowlplay4 View Post
int("123str") should really return -1 too
Definitely. Just because a string STARTS with numbers doesn't mean it's a number.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #10  
Old 08-17-2010, 05:21 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
This is the same behaviour as the various C functions for converting a string to integer or floating point value.
Reply With Quote
  #11  
Old 08-17-2010, 05:30 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Stefan View Post
This is the same behaviour as the various C functions for converting a string to integer or floating point value.
Perhaps, but it doesn't make any sense, you gotta agree on that much. At the very least could you add another function that doesn't think 123string49foobar equals the number 123?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #12  
Old 08-17-2010, 05:41 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Why the hell does Stefan have to do all the programming for you infants

stefan can you add a function to tie my shoelaces :'(
Reply With Quote
  #13  
Old 08-17-2010, 05:49 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Quote:
Originally Posted by Loriel View Post
Why the hell does Stefan have to do all the programming for you infants

stefan can you add a function to tie my shoelaces :'(
Too advanced Loriel. Make them yourself.
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #14  
Old 08-17-2010, 05:55 PM
Liberated Liberated is offline
not doing alot
Liberated's Avatar
Join Date: Feb 2008
Posts: 1,366
Liberated has a spectacular aura about
Quote:
Originally Posted by Loriel View Post
Why the hell does Stefan have to do all the programming for you infants
because we pay him for it?
__________________
Quote:
Originally Posted by Tigairius View Post
I promise when I get rich I'll send you an iPhone. I'll send everyone an iPhone.
Reply With Quote
  #15  
Old 08-17-2010, 06:04 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by Liberated View Post
because we pay him for it?
okay so since I am paying him too i am paying him not to change float() or add a new function or whatever
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 04:13 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.