Skip to main content

DEC2BIN

Converts a decimal number to binary.

Syntax

expression.DEC2BIN(arg1, arg2);

expression - A variable that represents a ApiWorksheetFunction class.

Parameters

NameRequired/OptionalData typeDefaultDescription
arg1RequiredApiRange | ApiName | numberThe decimal integer to convert.
arg2OptionalApiRange | ApiName | numberThe number of characters to use.

Returns

number

Example

Convert numbers from base 10 to base 2 format in a spreadsheet.

// What is a decimal number expressed as binary in a spreadsheet?

// Transform your decimal numbers into their binary equivalents in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.DEC2BIN(-100));