Hi,
I'd like an additional function that returns the complete string of bits instead of just the significant ones.
Something like:
To return from that string representation to its original Int value ,we already have function ParseInt. so
Note: unexpectedly ParseInt fails for negatives. For example:
Why did I post this wish? I was studying class B4xBitSet (which I like it a lot) and wanted to save the "block" entries (which for B4A/J are Ints) to their BinaryString representation in order to then save them in a Text field (or similar) in a database.
I'm aware of a function that returns booleans for each bit in the set in order to then use the Serializator, but once the set data array will be exposed (it will be a separate wish) it will be easier to put all the "blocks" together in a long string (and viceversa).
udg
I'd like an additional function that returns the complete string of bits instead of just the significant ones.
Something like:
B4X:
Sub ToBinaryString2(N As Int) As String
Dim filler As String = "00000000000000000000000000000000"
Dim sTest As String = Bit.ToBinaryString(N)
Return filler.SubString(sTest.Length)&sTest
End Sub
To return from that string representation to its original Int value ,we already have function ParseInt. so
B4X:
Log(Bit.ParseInt(ToBinaryString2(test),2))
Note: unexpectedly ParseInt fails for negatives. For example:
B4X:
Dim test As Int = -2
Dim s As String = Bit.ToBinaryString(test)
Log(Bit.ParseInt(s,2))
Why did I post this wish? I was studying class B4xBitSet (which I like it a lot) and wanted to save the "block" entries (which for B4A/J are Ints) to their BinaryString representation in order to then save them in a Text field (or similar) in a database.
I'm aware of a function that returns booleans for each bit in the set in order to then use the Serializator, but once the set data array will be exposed (it will be a separate wish) it will be easier to put all the "blocks" together in a long string (and viceversa).
udg
Last edited: