Created
April 28, 2022 21:25
-
-
Save thechriskent/cf46bb478fdeb60385a36918da47c1f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
If(CountRows(binaryDigits)=0, | |
ClearCollect(binaryDigits,[]); | |
ForAll(Sequence(8,7,-1), | |
Collect(binaryDigits, { | |
index: Value, | |
worth: Power(2,Value) | |
}) | |
) | |
); | |
ClearCollect(intToBinary,[]); | |
ClearCollect(asc,[]); | |
ForAll(Sequence(255), | |
With({ | |
firstDigit: CountRows(binaryDigits) - 1, //starting point depending on the number of binary digits | |
input: Value, | |
itbOffset: CountRows(intToBinary) | |
}, | |
ForAll(binaryDigits, | |
With({ | |
remainder: If(index = firstDigit, input, Last(intToBinary).remaining) //what's left to process (starts with input and decreases) | |
}, | |
Collect(intToBinary,{ | |
binary: If(remainder >= worth, "1", "0"), //Actual binary digit (left to right) | |
remaining: If(remainder >= worth, remainder - worth, remainder) //process what's left | |
}) | |
) | |
); | |
Collect(asc,{ | |
Num:Value, | |
Char:Char(Value), | |
Binary: With({full: Concat(LastN(intToBinary,CountRows(intToBinary)-itbOffset),binary)},Right(full,Len(full)-Find("1",full)+1)) | |
}) | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment