generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Number -> String

Previous Thread :: Next Thread 
ENET is not online. ENET
Joined: 01 Jan 2010
Total Posts: 4820
26 Mar 2012 05:30 PM
IN LUA:
--------------------------------------
number = 332152;
char = ""
while(number > 10)do
mod = number%10;
number = number-mod;
char = char..mod;
if(number > 0)then
number = number/10;
if(number < 10)then
char = char..tostring(number);
end
end

end

print(char:reverse());

In C++
--------------------------------------
char toString(int number){
if(number == 0) return '0';
if(number == 1) return '1';
if(number == 2) return '2';
if(number == 3) return '3';
if(number == 4) return '4';
if(number == 5) return '5';
if(number == 6) return '6';
if(number == 7) return '7';
if(number == 8) return '8';
if(number == 9) return '9';
}

int number = 100;
int i = 0;
char response[25];
while(number > 10 && i < 23){ //23 just for safety
int mod = number%10;
number = number-mod;
char[i] = toString(mod);
if(number > 0){
number = number/10;
if(number < 10){
char[i] = toString(number);
}
}
}

//C++ may need tweaking and I see room for improvment, but I am not able to compile it at the moment.
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
26 Mar 2012 05:33 PM
uuhhhhhhh
tostring(number)
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
26 Mar 2012 05:34 PM
You can use:

#include [cstdlib]

strtoul(number,0,10);


For C++.
Report Abuse
ENET is not online. ENET
Joined: 01 Jan 2010
Total Posts: 4820
26 Mar 2012 05:35 PM
Yeh, but I wanted to create a way that would be cross platform...
Report Abuse
ENET is not online. ENET
Joined: 01 Jan 2010
Total Posts: 4820
26 Mar 2012 05:36 PM
...and the inLua was just the concept of it...
Report Abuse
ENET is not online. ENET
Joined: 01 Jan 2010
Total Posts: 4820
26 Mar 2012 05:37 PM
I'm downloading visual c++ to my mom's school computer. :D Should have just gotten a lesser weighted program like code::blocks
Report Abuse
myrkos is not online. myrkos
Joined: 06 Sep 2010
Total Posts: 8072
26 Mar 2012 05:37 PM
strtoul is a C standard function, so it works pretty much everywhere that supports C.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image