Jump to content

Create your own text control codes: Difference between revisions

julia example
m (Was both a task and a draft task at the same time! Now just the latter.)
(julia example)
Line 56:
pop dx
ret</lang>
 
 
=={{header|Julia}}==
The example below extends the Base show function, as used to stringify printed output,
to allow formatting of larger numbers with commas and to print negative integers with parentheses.
<lang julia>using Formatting
import Base.show
 
Base.show(io::IO, x::Float64) = print(io, format(x, commas=true))
Base.show(io::IO, x::Int) = print(io, format(x, commas=true, parens=true))
 
println("15.1 + 31415926.5 = $(15.1 + 31415926.5)")
println("10000000000 / -3 = $(10000000000 / -3)")
println("2345 * 76 = $(2345 * 76), 2345 * -9876 = $(2345 * -9876)")
</lang>{{out}}
<pre>
15.1 + 31415926.5 = 31,415,941.6
10000000000 / -3 = -3,333,333,333.333333
2345 * 76 = 178,220 , 2345 * -9876 = (23,159,220)
</pre>
 
 
=={{header|Raku}}==
4,105

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.