![]() |
|
[.NET] BitBool, Set bits in a byte - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] BitBool, Set bits in a byte (/showthread.php?tid=4396680) |
BitBool, Set bits in a byte - sanderele1 - Aug 15, 2014 So basically this allows you to have 8 booleans in one byte, instead of the normal 1 bool for one byte. It also allows you to acces the shared GetBit and Setbit methods, so you can fuck around yourselves with tiny datatypes and whatnot. PHP Code - SetBool(Index As Integer, Value As Boolean) Set's a boolean at the specified index (0-7) to the specified value -GetBool(Index As Integer) As Boolean Get's the value of the boolean at the specified index (0-7) -ToByte() As Byte Returns a byte which contains all of the booleans -ToBools(IByte As Byte) Set's the booleans values to be the ones that are contained within the byte -Shared SetBit(IByte As Byte, Offset As Byte, Value As Boolean) As Byte Set's a bit at the specified offset to the value specified, inside of the specified Byte -Shared GetBit(IByte As Byte, Offset As Byte) As Boolean Returns a bit's value at the specified offset, in the specified byte Hopefully someone finds this helpfull. It's main purpose is to be used in networking. And please leave a constructive comment ^^ * - DBots - Aug 15, 2014 By doing this aren't you already using eight booleans? Code Dim InternalBools(7) As Boolean* - Temploit - Aug 15, 2014 (Aug 15, 2014 06:21 AM)DBots Wrote: By doing this aren't you already using eight booleans? Quote:So basically this allows you to have 8 booleans in one byte, instead of the normal 1 bool for one byte The code you provided requires 8 bytes of data (8 * 1 byte), but the method provided only requires 1 byte to store all 8 booleans. * - sanderele1 - Aug 15, 2014 (Aug 15, 2014 06:27 AM)Temploit Wrote: The code you provided requires 8 bytes of data (8 * 1 byte), but the method provided only requires 1 byte to store all 8 booleans. Yes it does, now have in mind this is made for networking as I stated. Meaning it has 8 booleans in memory, but when you are going to send it over a network. You simply send one byte. With the ToByte() function that is, and then you can re-assemble it on the other side. Using the ToBools(Byte) sub, hopefully that explained a bit. :) * - nuk - Aug 15, 2014 Hrmmm interesting.... something different on HF to say the least. Nice share homie :) * - SIM-1456245 - Aug 15, 2014 The concept is interesting, but I really think that you can store everything in one byte in the app itself aswell, try that. * - SIM-1847363 - Aug 15, 2014 Nice work, i will need to test this later, i like seeing something new keep up the good work. * - DeMoNi - Aug 16, 2014 Thanks, I will be using this for a custom encryption. * - Hopsin - Aug 16, 2014 Thank you. I'll try it out later, much appreciated * - Only3 - Aug 16, 2014 cuz i like ur class i will show u simple way Dim Bools() As Boolean = {True, False, True, True, False} Dim Ba As New BitArray(Bools) MsgBox(Ba.Get(0)) Ba.Set(0, False) MsgBox(Ba.Get(0)) http://msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx * - sanderele1 - Aug 17, 2014 (Aug 16, 2014 04:18 PM)Only3 Wrote: cuz i like ur class i will show u simple way I never saw that class :P That will certaintly make my life easier :D Thanks Only3, and thanks everyone that commented * - en3rgizz - Sep 22, 2015 Hrmmm interesting.... something different on HF to say the least * - ubbelol - Sep 22, 2015 Why do you declare all your parameters ByRef? * - sanderele1 - Sep 22, 2015 This post is so old, and mainly because I was a bit more stupid back then when I made this. As I understand it now, using ByVal copies the reference to an object, which is fine. Back then I thought it would create a new instance of the object and copy the data even when passing classes as parameters. Which would use 2x as much ram, or something like that. |