Minkowski question-mark function: Difference between revisions
→{{header|Julia}}
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 518:
=={{header|Julia}}==
<syntaxhighlight lang="julia">function
y, p =
d /= 2.0▼
y + d == y && break▼
else
end
end
end
function
while (
bit, bits = fldmod(2*bits, 1)
▲ curr, coun, i = 0, 1, 0
▲ i += 1
end
end▼
end
x, y = 0.718281828, 0.1213141516171819
for (a, b) ∈ [
(5/3, questionmark((1 + √5)/2)),
((√13-7)/6, questionmark_inv(-5/9)),
(x, questionmark_inv(questionmark(x))),
(y, questionmark(questionmark_inv(y)))]
println(a, a ≈ b ? " ≈ " : " != ", b)
</syntaxhighlight>{{out}}
<pre>
1.6666666666666667 ≈ 1.666666666667894
-0.5657414540893352 ≈ -0.5657414540893351
0.718281828 ≈ 0.7182818279999971
0.1213141516171819 ≈ 0.12131415161718095
</pre>
|