Variable size/Get: Difference between revisions

add RPL
(→‎{{header|Vlang}}: Rename "Vlang" in "V (Vlang)")
(add RPL)
 
(3 intermediate revisions by one other user not shown)
Line 756:
<syntaxhighlight lang="j">some_function =: +/ % #
7!:5<'some_function'</syntaxhighlight>
 
=={{header|Java}}==
<syntaxhighlight lang="java">
public final class VariableSize {
 
public static void main(String[] aArgs) {
System.out.println("A Byte variable occupies: " + Byte.SIZE / 8 + " byte");
System.out.println("A Char variable occupies: " + Character.SIZE / 8 + " bytes");
System.out.println("A Short variable occupies: " + Short.SIZE / 8 + " bytes");
System.out.println("A Float variable occupies: " + Float.SIZE / 8 + " bytes");
System.out.println("An Integer variable occupies: " + Integer.SIZE / 8 + " bytes");
System.out.println("A Double variable occupies: " + Double.SIZE / 8 + " bytes");
System.out.println("A Long variable occupies: " + Long.SIZE / 8 + " bytes");
}
 
}
</syntaxhighlight>
{{ out }}
<pre>
A Byte variable occupies: 1 byte
A Char variable occupies: 2 bytes
A Short variable occupies: 2 bytes
A Float variable occupies: 4 bytes
An Integer variable occupies: 4 bytes
A Double variable occupies: 8 bytes
A Long variable occupies: 8 bytes
</pre>
 
=={{header|Julia}}==
Line 1,228 ⟶ 1,255:
Size of list4 is : 7
Size of list5 is : 5
</pre>
 
=={{header|RPL}}==
Introduced only in 2003, the <code>BYTES</code> command returns both the checksum and the size of an object. Before, Hewlett-Packard provided a table in the user manual to do the math by yourself. Size can be not an integer, as objects are made of nibbles.
{{Works with|HP|49}}
« BYTES NIP » '<span style="color:blue">OBJSIZE</span>' STO
 
42 <span style="color:blue">OBJSIZE</span>
{ 1 2 3 "FOUR" (5,6) [7 8] } <span style="color:blue">OBJSIZE</span>
« BYTES NIP » <span style="color:blue">OBJSIZE</span>
{{out}}
<pre>
3: 6.5
2: 50
1: 20.5
</pre>
 
1,150

edits