Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-16-2011, 07:41 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Base-10 Converter

Here's something I needed. It's probably useless to most people. Convert positive base10 integers.

PHP Code:
function ConvertBase(targetbase) {
  if (
base == || base == 0) return 0;
  
temp.basestring "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
  
  while (
target 0) {
    
temp.newstring @= temp.basestring.charat(target base);
    
target int(target/base);
  }
  
  for (
temp.temp.newstring.length(); temp.>= 0temp.--) temp.output @= temp.newstring.substring(temp.i1);
  
  return 
temp.output;

Example of usage:
ConvertBase(5544, 2) converts the number 5544 to binary, 1010110101000.
ConvertBase(5544, 16) converts the number 5544 to base 16, 15A8.
ConvertBase(5544, 36) converts the number 5544 to base 36, 4A0.

Have fun.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #2  
Old 01-16-2011, 08:37 PM
Soala Soala is offline
Ideas on Fire
Soala's Avatar
Join Date: Jun 2007
Location: In my head
Posts: 3,208
Soala is a jewel in the roughSoala is a jewel in the rough
Nice, but I fail to see what it would be used for. I'd rather convert things myself, but if it's a real big number then maybe
Reply With Quote
  #3  
Old 01-16-2011, 09:28 PM
Codein Codein is offline
jwd
Codein's Avatar
Join Date: Oct 2005
Location: Greater Manchester
Posts: 2,423
Codein has a spectacular aura aboutCodein has a spectacular aura about
Send a message via AIM to Codein Send a message via MSN to Codein
Hahaha, that's cool. As you said, mostly useless, but still cool. Wouldn't be so bad when inspecting bitmasks, if anything.
Reply With Quote
  #4  
Old 01-16-2011, 09:51 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
Hey making useless stuff is my thing >

Whatever, nice job Tig.
__________________

Careful, thoughts and opinions here scare people.
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 08:59 AM.


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