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: binary script if anybody might find it useful

Previous Thread :: Next Thread 
S1xty is not online. S1xty
Joined: 25 Oct 2009
Total Posts: 2712
27 Feb 2015 03:18 AM
local module = {};

module.binInt = function(int)

local remainder = int;
local bin = {};
local count = 8;

for i = 1, 8 do
bin[i] = "0";
end

while remainder > 0 do
if remainder - 2^count >= 0 then
bin[8 - count] = "1";
remainder = remainder - 2^count;
if remainder == 0 then
return table.concat(bin);
end
count = count - 1;
else
count = count - 1;
end
end

end

module.toBinary = function(var)
if type(var) == "number" then
if var - math.floor(var) == 0 then
return module.binInt(var);
end
elseif type(var) == "table" then
local tab = {};
for i,v in pairs(var)do
tab[i] = module.binInt(v);
end
return tab;
else
error("Error, module.toBinary. Table or integer expected, got " .. type(var));
end
end

return module;



Basically to module.toBinary converts either an array of bytes or a single integer byte into a binary string or an array of binary strings. It could be useful for bitwise hashing functions.
Report Abuse
phoenix53124 is not online. phoenix53124
Joined: 25 Feb 2009
Total Posts: 4889
27 Feb 2015 03:32 AM
I like hash. I needed a hash function a while ago, but not anymore :(
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