-
Notifications
You must be signed in to change notification settings - Fork 19
/
get-DECtoBIN.pq
29 lines (29 loc) · 1.11 KB
/
get-DECtoBIN.pq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let
output = (input as number) =>
let
out = (if input <= 1 then Text.From(input) else "1")
& Text.Reverse(
Text.Combine(
List.Generate(
() => [result = null, actual = input],
each [actual] >= 1,
each
[
result = Text.From(Number.Mod([actual], 2)),
actual = Number.RoundDown([actual] / 2)
],
each [result]
)
)
)
in
out,
documentation = [
Documentation.Name = " get-DECtoBIN.pq ",
Documentation.Description = " Transfer decimal number to binary number. ",
Documentation.Source = "https://www.datameerkat.com . ",
Documentation.Version = " 1.0 ",
Documentation.Author = " Štěpán Rešl "
]
in
Value.ReplaceType(output, Value.ReplaceMetadata(Value.Type(output), documentation))