Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. If you don't like bit twiddling, look away now ...

If you don't like bit twiddling, look away now ...

Scheduled Pinned Locked Moved The Lounge
comgame-devalgorithmsquestionlounge
17 Posts 9 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • OriginalGriffO Offline
    OriginalGriffO Offline
    OriginalGriff
    wrote on last edited by
    #1

    If you do, watch the vid. But be aware that the "F-word" appears on screen several times, because it was included in the game code comments - and I can understand why ... that's about the one time I'd let it pass in my code as well. :laugh: Fast Inverse Square Root — A Quake III Algorithm - YouTube[^] That is so obvious once you've seen it! (The vid deserves a like purely for the quality of the explanation.) And a damn good introduction to IEEE 754 as well. :thumbsup:

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

    H J D S S 5 Replies Last reply
    0
    • OriginalGriffO OriginalGriff

      If you do, watch the vid. But be aware that the "F-word" appears on screen several times, because it was included in the game code comments - and I can understand why ... that's about the one time I'd let it pass in my code as well. :laugh: Fast Inverse Square Root — A Quake III Algorithm - YouTube[^] That is so obvious once you've seen it! (The vid deserves a like purely for the quality of the explanation.) And a damn good introduction to IEEE 754 as well. :thumbsup:

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      H Offline
      H Offline
      honey the codewitch
      wrote on last edited by
      #2

      I love this stuff. :)

      Real programmers use butterflies

      OriginalGriffO 1 Reply Last reply
      0
      • H honey the codewitch

        I love this stuff. :)

        Real programmers use butterflies

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Herself didn't understand why I was laughing out loud. She really didn't understand when I explained what I was watching ("IEEE 759, the International Standard for floating point number representation in computers" and a "square root calculating function") and that I was laughing with joy.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          If you do, watch the vid. But be aware that the "F-word" appears on screen several times, because it was included in the game code comments - and I can understand why ... that's about the one time I'd let it pass in my code as well. :laugh: Fast Inverse Square Root — A Quake III Algorithm - YouTube[^] That is so obvious once you've seen it! (The vid deserves a like purely for the quality of the explanation.) And a damn good introduction to IEEE 754 as well. :thumbsup:

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

          J Offline
          J Offline
          Jon McKee
          wrote on last edited by
          #4

          That's probably the best explanation for that algorithm I've seen so far :thumbsup:

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            If you do, watch the vid. But be aware that the "F-word" appears on screen several times, because it was included in the game code comments - and I can understand why ... that's about the one time I'd let it pass in my code as well. :laugh: Fast Inverse Square Root — A Quake III Algorithm - YouTube[^] That is so obvious once you've seen it! (The vid deserves a like purely for the quality of the explanation.) And a damn good introduction to IEEE 754 as well. :thumbsup:

            "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

            D Offline
            D Offline
            den2k88
            wrote on last edited by
            #5

            I loved that video, he should do more as he's very talented in explaining complex stuff.

            GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

            OriginalGriffO 1 Reply Last reply
            0
            • D den2k88

              I loved that video, he should do more as he's very talented in explaining complex stuff.

              GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

              OriginalGriffO Offline
              OriginalGriffO Offline
              OriginalGriff
              wrote on last edited by
              #6

              It's just so rare to find anything on YT where the author knows what he's talking about, and can explain it so well. He should do more.

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
              "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

              D M A 3 Replies Last reply
              0
              • OriginalGriffO OriginalGriff

                It's just so rare to find anything on YT where the author knows what he's talking about, and can explain it so well. He should do more.

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                D Offline
                D Offline
                den2k88
                wrote on last edited by
                #7

                I have a bunch of channels I love. MVG - Modern Vintage Gamer usually speaks about homebrew / how console were cracked; Coding Secrets is the channel of Sonic the Hedgehog programmer and explains how they did some "impossible" tricks on SEGA Genesis or PS1 hardware; Dring 4 Answers taught me more about engines, cars, turbines than I could ever imagine; Yarnhub, SimpleHistory and the Armchair Historian got me deeper into history than ever. I also follow an unholy number of gun channels and a bunch of swordmanship / medieval weapons channels.

                GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                OriginalGriffO P 3 Replies Last reply
                0
                • D den2k88

                  I have a bunch of channels I love. MVG - Modern Vintage Gamer usually speaks about homebrew / how console were cracked; Coding Secrets is the channel of Sonic the Hedgehog programmer and explains how they did some "impossible" tricks on SEGA Genesis or PS1 hardware; Dring 4 Answers taught me more about engines, cars, turbines than I could ever imagine; Yarnhub, SimpleHistory and the Armchair Historian got me deeper into history than ever. I also follow an unholy number of gun channels and a bunch of swordmanship / medieval weapons channels.

                  GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  Have a look at ThisOldTony as well - he's an amateur metalworker who explains things really well.

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  D 1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    Have a look at ThisOldTony as well - he's an amateur metalworker who explains things really well.

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                    D Offline
                    D Offline
                    den2k88
                    wrote on last edited by
                    #9

                    I see we speak the same language :laugh: :laugh:

                    GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                    1 Reply Last reply
                    0
                    • D den2k88

                      I have a bunch of channels I love. MVG - Modern Vintage Gamer usually speaks about homebrew / how console were cracked; Coding Secrets is the channel of Sonic the Hedgehog programmer and explains how they did some "impossible" tricks on SEGA Genesis or PS1 hardware; Dring 4 Answers taught me more about engines, cars, turbines than I could ever imagine; Yarnhub, SimpleHistory and the Armchair Historian got me deeper into history than ever. I also follow an unholy number of gun channels and a bunch of swordmanship / medieval weapons channels.

                      GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                      OriginalGriffO Offline
                      OriginalGriffO Offline
                      OriginalGriff
                      wrote on last edited by
                      #10

                      den2k88 wrote:

                      I also follow an unholy number of gun channels and a bunch of swordmanship / medieval weapons channels.

                      And appear on sooooo many "antiterrorism lists" ... :laugh:

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                      D 1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        den2k88 wrote:

                        I also follow an unholy number of gun channels and a bunch of swordmanship / medieval weapons channels.

                        And appear on sooooo many "antiterrorism lists" ... :laugh:

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                        D Offline
                        D Offline
                        den2k88
                        wrote on last edited by
                        #11

                        I got used to that the day I looked for some fun takes on N*zi propaganda (i.e. the video of Born to be Alive with Mr. Moustache "dancing" to it) but of course YouTube collected it under N*zi videos. Alongside black metal, swords, guns, explosives. So yeah, I am on at least a dozen no-fly lists.

                        GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                        1 Reply Last reply
                        0
                        • D den2k88

                          I have a bunch of channels I love. MVG - Modern Vintage Gamer usually speaks about homebrew / how console were cracked; Coding Secrets is the channel of Sonic the Hedgehog programmer and explains how they did some "impossible" tricks on SEGA Genesis or PS1 hardware; Dring 4 Answers taught me more about engines, cars, turbines than I could ever imagine; Yarnhub, SimpleHistory and the Armchair Historian got me deeper into history than ever. I also follow an unholy number of gun channels and a bunch of swordmanship / medieval weapons channels.

                          GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                          P Offline
                          P Offline
                          Peter Shaw
                          wrote on last edited by
                          #12

                          Tom Scott's channel is highly recomended, esp if your a brit.

                          D 1 Reply Last reply
                          0
                          • P Peter Shaw

                            Tom Scott's channel is highly recomended, esp if your a brit.

                            D Offline
                            D Offline
                            den2k88
                            wrote on last edited by
                            #13

                            I watch his videos occasionally, he's fine but a bit all over the place, I prefer very specific channels with in depth explanations. Though Tom Scott often piques my curiosity with interesting trivia.

                            GCS d--(d-) s-/++ a C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- r+++ y+++*      Weapons extension: ma- k++ F+2 X

                            1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              It's just so rare to find anything on YT where the author knows what he's talking about, and can explain it so well. He should do more.

                              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                              M Offline
                              M Offline
                              MKJCP
                              wrote on last edited by
                              #14

                              If you like music, you should check out Rick Beato, especially the "what makes the song great" series.

                              1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                It's just so rare to find anything on YT where the author knows what he's talking about, and can explain it so well. He should do more.

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                A Offline
                                A Offline
                                Alister Morton
                                wrote on last edited by
                                #15

                                Check out bigclive - very good.

                                1 Reply Last reply
                                0
                                • OriginalGriffO OriginalGriff

                                  If you do, watch the vid. But be aware that the "F-word" appears on screen several times, because it was included in the game code comments - and I can understand why ... that's about the one time I'd let it pass in my code as well. :laugh: Fast Inverse Square Root — A Quake III Algorithm - YouTube[^] That is so obvious once you've seen it! (The vid deserves a like purely for the quality of the explanation.) And a damn good introduction to IEEE 754 as well. :thumbsup:

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                  S Offline
                                  S Offline
                                  sasadler
                                  wrote on last edited by
                                  #16

                                  As an ex-embedded engineer (retired now), I love bit twiddling and fast approximations. I never need this particular approximation but it's very clever and probably not something I'd ever figure out on my own.

                                  1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    If you do, watch the vid. But be aware that the "F-word" appears on screen several times, because it was included in the game code comments - and I can understand why ... that's about the one time I'd let it pass in my code as well. :laugh: Fast Inverse Square Root — A Quake III Algorithm - YouTube[^] That is so obvious once you've seen it! (The vid deserves a like purely for the quality of the explanation.) And a damn good introduction to IEEE 754 as well. :thumbsup:

                                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                    S Offline
                                    S Offline
                                    Stefan_Lang
                                    wrote on last edited by
                                    #17

                                    Interesting, but I have some doubts it is still relevant with modern compilers and CPUs. Even if it were, a simple lookup table would be faster for the purpose of finding the first estimation. This algortihm reminds me a bit of Bresenham's line algorithm - Wikipedia[^] : extremely clever, but once it was hard-wired in every graphcs chip there was little point knowing about it. Except maybe to apply such principles to similar problems in other areas. E. g. I tend to do calculations with 2D and 3D vectors a lot, and if I were to do these calculations straightforward, then yes, I'd need to do a lot of vector normalizations (i. e. calculations of 1/sqrt(x)). But in about 8-9 out of 10 cases I can avoid normalization alltogether by transforming the expressions. E. g. when I want to know whether a vector length is very small (effectively null), then I compare the squared length against the squared threshold value. Or when I calculate the intersection of a plane with a line, I determine the intersection without normalizing any vector. Instead I transform the equations in such a way that I end up with the squared length of the line direction vector, and the plane direction or normal vectors don't need to be normalized at all. I do agree that the explanations and specifically the animated number representations are formidable, though

                                    GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

                                    1 Reply Last reply
                                    0
                                    Reply
                                    • Reply as topic
                                    Log in to reply
                                    • Oldest to Newest
                                    • Newest to Oldest
                                    • Most Votes


                                    • Login

                                    • Don't have an account? Register

                                    • Login or register to search.
                                    • First post
                                      Last post
                                    0
                                    • Categories
                                    • Recent
                                    • Tags
                                    • Popular
                                    • World
                                    • Users
                                    • Groups