Literals/Integer: Difference between revisions

Content deleted Content added
Aerobar (talk | contribs)
add RPL
Gaham (talk | contribs)
 
(8 intermediate revisions by 8 users not shown)
Line 26:
print(1111'1111b) // binary literal
print(255'000) // decimal literal</syntaxhighlight>
 
{{out}}
<pre>
Line 37 ⟶ 36:
255000
</pre>
=={{header|4ME}}==
P:
out{255} literal
 
=={{header|6502 Assembly}}==
Conventions vary between assemblers, but typically a $ represents hexadecimal and a % represents binary. The absence of either of those symbols means decimal. Single or double quotes represent an ASCII value. Keep in mind that without a # in front, any quantity is interpreted as a dereference operation at the memory location equal to the supplied number, rather than a constant value.
Line 504 ⟶ 507:
PRINT BIN(10001)
PRINT ORD(HEX$("11"))</syntaxhighlight>
 
==={{header|SmallBASIC}}===
<syntaxhighlight lang="qbasic">
print 255 ' Decimal
print 0xFF ' Hexadecimal
print 0hFF ' Hexadecimal
print &xFF ' Hexadecimal
print &hFF ' Hexadecimal
print 0o377 ' Octal
print &o377 ' Octal
print 0b11111111 ' Binary
print &b11111111 ' Binary
</syntaxhighlight>
 
==={{header|Yabasic}}===
Line 623 ⟶ 639:
return 0;
}</syntaxhighlight>
 
=={{header|Cherrycake}}==
 
<syntaxhighlight lang="cherrycake">
515142 # Interpretted as an integer, 515142
0b10111011 # Interpretted as a binary integer, 10111011 (187)
0x0AB3 # Interpretted as a binary integer, 0AB3 (2739)
</syntaxhighlight>
 
=={{header|Clojure}}==
Line 1,151 ⟶ 1,175:
every write(!L)
end</syntaxhighlight>
 
=={{Header|Insitux}}==
 
<syntaxhighlight lang="insitux">
[123 0x7F 0xFFF 0b0101001]
</syntaxhighlight>
 
{{out}}
 
<pre>
[123 127 4095 41]
</pre>
 
=={{header|J}}==
Line 2,049 ⟶ 2,085:
#13Ah
 
=={{header|RPL}}==
#1011b <span style="color:grey">@ Base 2</span>
#1234o <span style="color:grey">@ Base 8</span>
#6789d <span style="color:grey">@ Base 10</span>
#ABCDh <span style="color:grey">@ Base 16</span>
=={{header|Ruby}}==
 
Line 2,263 ⟶ 2,304:
<syntaxhighlight lang="usala">t = 4534934521_</syntaxhighlight>
is used for numbers stored in binary converted decimal format, also with unlimited precision, which may perform better in applications involving very large decimal numbers.
 
=={{header|Uxntal}}==
Uxntal only allows hexadecimal literals, and they can be either one or two bytes. In order to push them to the stack, rather than writing them directly to the assembled binary, they must be prefixed with <code>#</code>.
<syntaxhighlight lang="Uxntal">#2a ( byte literal )
#c0de ( short literal )</syntaxhighlight>
And yes, they do have to be in lowercase hex.
 
=={{header|Verbexx}}==
Line 2,339 ⟶ 2,386:
End Sub</syntaxhighlight>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="Vlang">
fn main() {
w := 727
x := 0x2d7
y := 0o1327
z := 0b10110_10111
println([w, x, y, z])
}
</syntaxhighlight>
 
{{out}}
<pre>
[727, 727, 727, 727]
</pre>
 
=={{header|Wren}}==
Line 2,348 ⟶ 2,411:
 
As the only difference between integers and other numbers is that the former do not have a decimal part, it is also possible to represent integers using scientific notation.
<syntaxhighlight lang="ecmascriptwren">var a = 255
var b = 0xff
var c = 0255 // not an octal literal