Variable size/Get: Difference between revisions

add RPL
(Applesoft BASIC)
(add RPL)
 
(5 intermediate revisions by 3 users 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 975 ⟶ 1,002:
# sizeof(Array.init 10 (fun _ -> String.create 20)) ;;
- : int = 61</syntaxhighlight>
 
=={{header|Odin}}==
 
<syntaxhighlight lang="odin">package main
 
import "core:fmt"
 
main :: proc() {
fmt.println("An int contains", size_of(int), "bytes.")
}</syntaxhighlight>
 
=={{header|Ol}}==
Line 1,218 ⟶ 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>
 
Line 1,434 ⟶ 1,486:
}</syntaxhighlight>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="textv (vlang)">sizeof(i64)</syntaxhighlight>
{{out}}
<pre>8</pre>
1,150

edits