Skip to content

Instantly share code, notes, and snippets.

@thechriskent
Created April 27, 2022 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thechriskent/801ee3afddee312304510c58b7b90403 to your computer and use it in GitHub Desktop.
Save thechriskent/801ee3afddee312304510c58b7b90403 to your computer and use it in GitHub Desktop.
ClearCollect(binaryToInt,[]);
With({
input: txtFromBinary.Text
},
ForAll(Sequence(Len(input)),
With({
binaryDigit: Right(Left(input,Len(input)-(Value-1)),1) //Grab the right most digit
},
Collect(binaryToInt,{
binaryDigit: binaryDigit, //Not necessary (debug)
value:If(binaryDigit = "1", Power(2,Value-1), 0), //Not necessary (debug)
runningTotal:If(binaryDigit = "1", Power(2,Value-1), 0) + If(Value=1, 0, Last(binaryToInt).runningTotal)
})
)
)
);
Set(intResult,Last(binaryToInt).runningTotal);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment