From 7a124f17f39a26288ffb964a646f8b94813f7b2f Mon Sep 17 00:00:00 2001 From: anastasosmoho Date: Thu, 1 Oct 2026 18:05:01 +0000 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C=20wo?= =?UTF-8?q?rks/pr2/3fast=5Finverse=5Fsquare=5Froot=5Fquacklll/main3.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main3.cpp | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 works/pr2/3fast_inverse_square_root_quacklll/main3.cpp diff --git a/works/pr2/3fast_inverse_square_root_quacklll/main3.cpp b/works/pr2/3fast_inverse_square_root_quacklll/main3.cpp deleted file mode 100644 index c76f920..0000000 --- a/works/pr2/3fast_inverse_square_root_quacklll/main3.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -float Q_rsqrt(float number){ - int32_t i; - float x2, y; - const float threehalfs = 1.5f; - x2 = number * 0.5f; - y = number; - // 1. "магический" битовый хак - memcpy(&i, &y, sizeof(i)); - i = 0x5f3759df - (i >> 1); // <- магия - memcpy(&y, &i, sizeof(y)); // обратно в float - y = y * (threehalfs - (x2 * y * y)); - return y; -} - -int main(void) { - for (float x = 0.5f; x <= 4.0f; x += 0.5f){ - printf("x=%.1f 1/sqrt(x) ~= %.6f\n", x, Q_rsqrt(x)); - } - return 0; - -} - \ No newline at end of file