-
Notifications
You must be signed in to change notification settings - Fork 0
/
code-invsqrt.html
44 lines (42 loc) · 1.48 KB
/
code-invsqrt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="monokai.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" charset="utf-8"></script>
<script src="highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body>
<button id="button1" onclick="CopyToClipboard('copy-code-invsqrt')" class="fas fa-copy" style="color:dimgrey; background: none; padding:1px; border: none;"></button>
<div class="border" style="background-color:444;">
<pre><code class="language-java" id="copy-code-invsqrt">public static float invSqrt(float x) {
float xhalf = 0.5f * x;
int i = Float.floatToIntBits(x);
i = 0x5f3759df - (i >> 1);
x = Float.intBitsToFloat(i);
x *= (1.5f - xhalf * x * x);
return x;
}
</code></pre>
</div>
<script>
function CopyToClipboard(containerid) {
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select().createTextRange();
document.execCommand("copy");
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
document.execCommand("copy");
}
}
</script>
</body>
</html>