Variable size/Set: Difference between revisions

New post.
No edit summary
(New post.)
Line 501:
 
Here, v is specified to have a minimum size. In this case, the minimum size of the content is zero, though the size of the representation is somewhat larger.
 
=={{header|Java}}==
Java's primitive types are fixed in size. If a programmer wants a numeric type to be able to accommodate
 
a certain size of number, up to a maximum of eight bytes, then they declare a variable of the appropriate type.
 
If more than eight bytes of precision is required they can use either BigInteger or BigDecimal.
<syntaxhighlight lang="java">
public final class VariableSizeSet {
 
public static void main(String[] args) {
System.out.println("The ranges of Java's primitive data types are:");
System.out.println();
System.out.println("A Byte variable has a range of " + Byte.MIN_VALUE + " to " + Byte.MAX_VALUE);
System.out.println("A Short variable has a range of " + Short.MIN_VALUE + " to " + Short.MAX_VALUE);
System.out.println("An Int variable has a range of " + Integer.MIN_VALUE + " to " + Integer.MAX_VALUE);
System.out.println("A Long variable has a range of " + Long.MIN_VALUE +" to " + Long.MAX_VALUE);
System.out.println("A Float variable has a range of " + Float.MIN_VALUE + " to " + Float.MAX_VALUE);
System.out.println("A Double variable has a range of " + Double.MIN_VALUE + " to " + Double.MAX_VALUE);
}
 
}
</syntaxhighlight>
{{ out }}
<pre>
The ranges of Java's primitive data types are:
 
A Byte variable has a range of -128 to 127
A Short variable has a range of -32768 to 32767
An Int variable has a range of -2147483648 to 2147483647
A Long variable has a range of -9223372036854775808 to 9223372036854775807
A Float variable has a range of 1.4E-45 to 3.4028235E38
A Double variable has a range of 4.9E-324 to 1.7976931348623157E308
</pre>
 
=={{header|Julia}}==
884

edits