Skip to main content Link Search Menu Expand Document Toggle dark mode Copy Code (external link)

long() : Convert to Long Integer

Convert a value to a 64-bit long integer. Useful for large numbers that exceed Int32 range.


On this page

Signature

long(value)

Parameters

Parameter Type Required Description
value Any Yes The value to convert to long integer

Returns

Type: Int64

A 64-bit integer representation of the value.


Examples

Large Number Conversion

<p>Population: {{format(long(model.population), 'N0')}}</p>

Data:

doc.Params["model"] = new {
    population = "7800000000"
};

Output:

<p>Population: 7,800,000,000</p>

File Size Calculation

<p>Total Size: {{format(long(model.bytes) / 1024 / 1024, '0.00')}} MB</p>

Data:

doc.Params["model"] = new {
    bytes = "52428800"
};

Output:

<p>Total Size: 50.00 MB</p>

Timestamp Conversion

<p>Timestamp: {{long(model.timestamp)}}</p>

Data:

doc.Params["model"] = new {
    timestamp = "1679875200000"
};

Output:

<p>Timestamp: 1679875200000</p>

Notes

  • Truncates decimal places (does not round)
  • Handles string-to-long conversion
  • Throws exception if value cannot be converted
  • Range: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807
  • Use for large numbers that exceed Int32 range (-2.1B to 2.1B)
  • For decimal precision, use decimal() instead

See Also