Literals/Integer: Difference between revisions

Content deleted Content added
Add Seed7 example
Rdm (talk | contribs)
J: some comments about types
Line 465: Line 465:


Internally, J freely [http://www.jsoftware.com/help/dictionary/dictg.htm converts] fixed precision integers to floating point numbers when they overflow, and numbers (including integers) of any type may be combined using any operation where they would individually be valid arguments.
Internally, J freely [http://www.jsoftware.com/help/dictionary/dictg.htm converts] fixed precision integers to floating point numbers when they overflow, and numbers (including integers) of any type may be combined using any operation where they would individually be valid arguments.

Internally, J represents numeric constants in their simplest type, regardless of how they were specified. In other words 9r1, although it is "specified as a rational" is represented as an extended precision integer. Similarly, 2.0, although it is "specified as a floating point value" is represented as an integer, and 1.0 is represented as a boolean.

That said, note that "type" is a property of the array, and not a property of the value. And, code that modifies the structure of an array leaves its type alone. So, if you need an array of a type different than that specified by J's "simplest type for constants" rule, you can extract the constant you need from an array which contains it and has the type you need. For example <code>{.1 2</code> would give you an integer 1 instead of a boolean 1.


=={{header|Java}}==
=={{header|Java}}==