Call of Duty 5: World at War => Tutorial Desk => Scripting => Topic started by: JR-Imagine on October 10, 2015, 10:30:11 pm
Title: [Function] Converting a string to a floating point number
Post by: JR-Imagine on October 10, 2015, 10:30:11 pm
I got bored so decided to write some random functions and ended up writing something that might be somewhat useful to someone... It converts a string to a floating point number (or integer if it's not a decimal number). Have fun:
Example usage:
Title: Re: [Function] Converting a string to a floating point number
Post by: Soy-Yo on October 10, 2015, 11:04:23 pm
Haven't you think on people like me, who use a ' instead of a point or a comma? :alone:
Interesting fact: in Spain we use the point where you use the comma and the comma where you use the point. :P Don't know if other countries do the same.
Anyway, good function. I thought it was done automatically by the game (it should >:().
Title: Re: [Function] Converting a string to a floating point number
Post by: Harry Bo21 on October 10, 2015, 11:08:21 pm
Haven't you think on people like me, who use a ' instead of a point or a comma? :alone:
Interesting fact: in Spain we use the point where you use the comma and the comma where you use the point. :P Don't know if other countries do the same.
Anyway, good function. I thought it was done automatically by the game (it should >:().
funny you say that, the BO2 decompiled code often substitutes "." for ",", meaning i have to track all instances down. In some args, can look too complicated lol
wait 0,1; is the most common i seem to find
usually , is to define a tenth or a thousand, or for grammar
10,000 = ten thousand, the , is just to make it "clearer"
i see its actually more countries use the comma version than our point version too ? lol
Quote
Countries using Arabic numerals with decimal point[edit] Countries where a dot "." is used as decimal mark include:
Australia Bangladesh Botswana British West Indies Brunei Canada (when using English) China, People's Republic of Dominican Republic Egypt Ghana Guatemala Honduras Hong Kong India Ireland Israel Japan Jordan Kenya Korea (both North and South) Lebanon Luxembourg (uses both marks officially) Macau (in Chinese and English text) Malaysia Malta Mexico Mongolia Nepal New Zealand Nicaragua Nigeria Pakistan Palestine Panama Philippines Singapore Sri Lanka Switzerland Taiwan Tanzania Thailand Uganda United Kingdom United States (including insular areas) Zimbabwe
Countries using Arabic numerals with decimal comma[edit] Countries where a comma "," is used as decimal mark include:
Albania Algeria Andorra Angola Argentina Armenia Austria Azerbaijan Belarus Belgium Bolivia Bosnia and Herzegovina Brazil Bulgaria Cameroon Canada (when using French) Chile Colombia Costa Rica Croatia (comma used officially, but both forms are in use) Cuba Cyprus Czech Republic Denmark East Timor Ecuador Estonia Faroes Finland France Germany Georgia Greece Greenland Hungary Iceland Indonesia Italy Kazakhstan Kosovo Kyrgyzstan Latvia Lebanon Lithuania Luxembourg (uses both marks officially) Macau (in Portuguese text) Macedonia Moldova Mongolia Morocco Mozambique Namibia The Netherlands Norway Paraguay Peru Poland Portugal Romania Russia Serbia Slovakia Slovenia South Africa Spain Switzerland Sweden Tunisia Turkey Ukraine Uruguay Uzbekistan Venezuela Vietnam
Title: Re: [Function] Converting a string to a floating point number
Post by: Soy-Yo on October 10, 2015, 11:24:10 pm
funny you say that, the BO2 decompiled code often substitutes "." for ",", meaning i have to track all instances down. In some args, can look too complicated lol
wait 0,1; is the most common i seem to find
usually , is to define a tenth or a thousand, or for grammar
10,000 = ten thousand, the , is just to make it "clearer"
i see its actually more countries use the comma version than our point version too ? lol
Again no one thinks on people who use this '. :alone: I think this time it has been Wikipedia, hasn't it? I didn't know we were more lol. I thought more countries used the dot for decimals.
And I use 10 000 for ten thousand (with a little space to make it clearer). And 0'1 for decimals.
Title: Re: [Function] Converting a string to a floating point number
Post by: Harry Bo21 on October 10, 2015, 11:34:05 pm
Again no one thinks on people who use this '. :alone: I think this time it has been Wikipedia, hasn't it? I didn't know we were more lol. I thought more countries used the dot for decimals.
And I use 10 000 for ten thousand (with a little space to make it clearer). And 0'1 for decimals.
yes it was from wiki, and if you look he actually allowed for both
Title: Re: [Function] Converting a string to a floating point number
Post by: Dust on October 11, 2015, 12:14:27 am
That explains why when I talk to other people from other countries they use "," instead of "." I always thought it was a typo :poker:
Title: Re: [Function] Converting a string to a floating point number
Post by: Harry Bo21 on October 11, 2015, 12:17:31 am
That explains why when I talk to other people from other countries they use "," instead of "." I always thought it was a typo :poker:
lol me too, and i thought the bo2 gscs were some sort of problem during the decryption process. When Im gonna assume now that they were decompiled from a Spanish version or something maybe
Title: Re: [Function] Converting a string to a floating point number
Post by: alaurenc9 on October 11, 2015, 06:17:00 pm
this function already exists in _zombiemode_utility btw, it is called string_to_float(). the one in world at war is a bit buggy however, but i found a perfectly working one in the black ops 1 version of _zombiemode_utility