Non-decimal radices/Output: Difference between revisions

Content added Content deleted
Line 305: Line 305:
WRITE(Format="b6.0, o4.0, i4.0, z4.0") n, n, n, n
WRITE(Format="b6.0, o4.0, i4.0, z4.0") n, n, n, n
ENDDO</lang>
ENDDO</lang>

=={{header|Icon}} and {{header|Unicon}}==
Strictly speaking output conversion to different representations isn't built-in to Icon and Unicon; however, printf is included as part of the standard library.
<lang Icon>rocedure main()
write("Non-decimal radices/Output")
every i := 255 | 2 | 5 | 16 do {
printf("%%d = %d\n",i) # integer format
printf("%%x = %x\n",i) # hex format
printf("%%o = %o\n",i) # octal format
printf("%%s = %s\n",i) # string format
printf("%%i = %i\n",i) # image format
}
end</lang>

{{libheader|Icon Programming Library}}
[http://www.cs.arizona.edu/icon/library/src/procs/printf.icn printf.icn provides printf, fprintf, and sprintf]
{{libheader|Unicon Code Library}}

Output:<pre>%d = 255
%x = ff
%o = 377
%s = 255
%i = 255
...</pre>


=={{header|J}}==
=={{header|J}}==