September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
21
Task/Literals-Integer/Ring/literals-integer.ring
Normal file
21
Task/Literals-Integer/Ring/literals-integer.ring
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
see "Decimal literal = " + 1234 + nl
|
||||
see "Hexadecimal literal = " + dec("4D2") + nl
|
||||
see "Octal Literal = " + octal(668) + nl
|
||||
see "Binary literal = " + bintodec("10011010010")
|
||||
|
||||
func bintodec(bin)
|
||||
binsum = 0
|
||||
for n=1 to len(bin)
|
||||
binsum = binsum + number(bin[n]) *pow(2, len(bin)-n)
|
||||
next
|
||||
return binsum
|
||||
|
||||
func octal m
|
||||
output = ""
|
||||
w = m
|
||||
while fabs(w) > 0
|
||||
oct = w & 7
|
||||
w = floor(w / 8)
|
||||
output = string(oct) + output
|
||||
end
|
||||
return output
|
||||
Loading…
Add table
Add a link
Reference in a new issue