Forum Discussion
smpa01
Community Champion
5 years agoInteger/Decimal to Binary in PQ
Does PQ currently have any syntax that converts an integer /decimal value to Binary.
I looked into the documentation and could not find anything
e.g.
52 = 110100,
137.5879541 = 10001001.10010110100001000010100011101111000011001001
https://www.rapidtables.com/convert/number/decimal-to-binary.html
Thank you in advance
mahoneypat this is mine and only for integer but I even have a better solution than this, getting blogged out.
let Source = (p1 as number) => let Loop = List.Generate( () => [i = p1, j = Number.IntegerDivide(i, 2), k = Number.Mod(i, 2), l = Text.From(k)], each [i] > 0, each [i = [j], j = Number.IntegerDivide(i, 2), k = Number.Mod(i, 2), l = Text.From(k) & [l]], each [l] ) in Loop{List.Count(Loop) - 1}, Source1 = {1..100}, #"Converted to Table" = Table.FromList(Source1, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each fx([Column1])) in #"Added Custom"