formatBaseN

String Converts number to a string, in the base specified by radix.

formatBaseN(number, radix) → returns string

formatBaseN Argument Reference

number numeric
Required

radix numeric
Required

Examples sample code invoking the formatBaseN function


Format 10 as dual number

formatBaseN(10,2)

Expected Result: 1010


Format 1024 as hexadecimal number

formatBaseN(1024,16)

Expected Result: 400


Format 125 as decimal number

formatBaseN(125,10)

Expected Result: 125


Format a float

Floors float to integer then formats with radix given

formatBaseN(10.75,2)

Expected Result: 1010


Fork me on GitHub