Skip to content

Commit

Permalink
Document the "L" needed for long integer literals
Browse files Browse the repository at this point in the history
  • Loading branch information
gohai committed Feb 10, 2017
1 parent ae87b86 commit f4a2e53
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions content/api_en/include/long.xml
Expand Up @@ -11,16 +11,18 @@
<example>
<image></image>
<code><![CDATA[
long a; // Declare variable 'a' of type long
a = 23; // Assign 'a' the value 23
long b = -256; // Declare variable 'b' and assign it the value -256
long c = a + b; // Declare variable 'c' and assign it the sum of 'a' and 'b'
int i = (int)c; // Converts the value of 'c' from a long to an int
long a; // Declare variable 'a' of type long and assign a large value:
//a = 2147483648; // Error: The literal of type int is out of range
a = 2147483648L; // Instead, add an "L" to the number to mark it as a long
long b = -256; // Declare variable 'b' and assign it the value -256
long c = a + b; // Declare variable 'c' and assign it the sum of 'a' and 'b'
int i = (int)c; // Converts the value of 'c' from a long to an int
]]></code>
</example>

<description><![CDATA[
Datatype for large integers. While integers can be as large as 2,147,483,647 and as low as -2,147,483,648 (stored as 32 bits), a <b>long</b> integer has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (stored as 64 bits). Use this datatype when you need a number to have a greater magnitude than can be stored within an <b>int</b>. Processing functions don't use this datatype, so while they work in the language, you'll usually have to convert to a <b>int</b> using the <b>(int)</b> syntax before passing into a function.
Datatype for large integers. While integers can be as large as 2,147,483,647 and as low as -2,147,483,648 (stored as 32 bits), a <b>long</b> integer has a minimum value of -9,223,372,036,854,775,808 and a maximum value of 9,223,372,036,854,775,807 (stored as 64 bits). Use this datatype when you need a number to have a greater magnitude than can be stored within an <b>int</b>. When assigning literal values that are larger than this magnitude, it is necessary to also append the qualifier "L" to the number, as shown in the example above. Processing functions don't use this datatype, so while they work in the language, you'll usually have to convert to a <b>int</b> using the <b>(int)</b> syntax before passing into a function.
]]></description>

<syntax>
Expand Down

0 comments on commit f4a2e53

Please sign in to comment.