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. Floating Point Math

Floating Point Math

Scheduled Pinned Locked Moved The Lounge
csharpdatabasecomtoolsquestion
40 Posts 24 Posters 1 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.
  • L Lost User

    OriginalGriff wrote:

    Depends how fast I can move, and the size and initial distance to the storm.

    Size! ..that's the thing I did not take into account. Ah, just a small bug :laugh:

    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

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

    There's always something, isn't there? :laugh:

    Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

    "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

    L 1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      There's always something, isn't there? :laugh:

      Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952) Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #22

      Not always, but very often :rolleyes:

      1 Reply Last reply
      0
      • C Chris Losinger

        no, BYTEs. doubles are 8 bytes each. 3x8 = 24 bytes.

        image processing toolkits | batch image processing

        E Offline
        E Offline
        enhzflep
        wrote on last edited by
        #23

        Chris Losinger wrote:

        but need to convert the input to doubles for the internals

        :doh: Of course. Must be about time for bed for me... Those images sure do get pretty big, pretty quick, at that rate of memory consumption.

        1 Reply Last reply
        0
        • E Ennis Ray Lynch Jr

          Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

          D Offline
          D Offline
          Dr Walt Fair PE
          wrote on last edited by
          #24

          I work on stuff where 15 digits is marginally OK, using plenty of trickery.

          CQ de W5ALT

          Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software

          1 Reply Last reply
          0
          • L Lost User

            OriginalGriff wrote:

            Depends how fast I can move, and the size and initial distance to the storm.

            Size! ..that's the thing I did not take into account. Ah, just a small bug :laugh:

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #25

            Eddy Vluggen wrote:

            Size!

            It does matter apparently!

            Eddy Vluggen wrote:

            Ah, just a small bug

            That's what she said.

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • C Chris Maunder

              Someone, somewhere, is thinking "I am a hurricane damage simulator".

              cheers Chris Maunder

              N Offline
              N Offline
              Nagy Vilmos
              wrote on last edited by
              #26

              Sean been at the hamsters' sunflower hooch again?

              1 Reply Last reply
              0
              • E Ennis Ray Lynch Jr

                Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #27

                I'll have my math float away, thank you! :D

                It's an OO world.

                public class SanderRossel : Lazy<Person>
                {
                public void DoWork()
                {
                throw new NotSupportedException();
                }
                }

                J 1 Reply Last reply
                0
                • E Ennis Ray Lynch Jr

                  Mine isn't nearly as accurate. Wind fields in real-life are surprisingly non-deterministic and literally change with the phase of the moon.

                  Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                  Sander RosselS Offline
                  Sander RosselS Offline
                  Sander Rossel
                  wrote on last edited by
                  #28

                  Ennis Ray Lynch, Jr. wrote:

                  and literally change with the phase of the moon.

                  So do I! Oh no... It's a full moo OOOOOOOOOOH!!! *Howl*

                  It's an OO world.

                  public class SanderRossel : Lazy<Person>
                  {
                  public void DoWork()
                  {
                  throw new NotSupportedException();
                  }
                  }

                  J 1 Reply Last reply
                  0
                  • E Ennis Ray Lynch Jr

                    Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                    Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                    G Offline
                    G Offline
                    greldak
                    wrote on last edited by
                    #29

                    Depends what I need to do - for some things I don't need either, others will need precision and also accuracy in which case there's no point getting the wrong answer instantly, others I just need an estimate but I need it quickly

                    1 Reply Last reply
                    0
                    • E Ennis Ray Lynch Jr

                      Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

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

                      Most of my work, 4 byte floats are too inaccurate. Some of my work, doubles barely suffice. All of my work, speed matters. Conclusion: I need both, and I need it yesterday! ;P

                      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
                      • E Ennis Ray Lynch Jr

                        Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                        Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                        D Offline
                        D Offline
                        Duncan Edwards Jones
                        wrote on last edited by
                        #31

                        Sometimes you can solve/reduce floating point problems by scaling up - always recording your prices in pennies not dollars for example and your hurricane strength in metric butterflies.

                        1 Reply Last reply
                        0
                        • E Ennis Ray Lynch Jr

                          Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                          D Offline
                          D Offline
                          Dan Neely
                          wrote on last edited by
                          #32

                          4 base 10 digits would generally be OK if the internal representation was base 10 also. Even with all the digits an IEEE754 64bit float provides, weirdness from the inability to represent 0.1 precisely in binary has an obnoxious habit of leaking into userspace.

                          Did you ever see history portrayed as an old man with a wise brow and pulseless heart, waging all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                          1 Reply Last reply
                          0
                          • E Ennis Ray Lynch Jr

                            Mine isn't nearly as accurate. Wind fields in real-life are surprisingly non-deterministic and literally change with the phase of the moon.

                            Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                            J Offline
                            J Offline
                            J Julian
                            wrote on last edited by
                            #33

                            But phases of the moon are VERY deterministic.

                            1 Reply Last reply
                            0
                            • Sander RosselS Sander Rossel

                              Ennis Ray Lynch, Jr. wrote:

                              and literally change with the phase of the moon.

                              So do I! Oh no... It's a full moo OOOOOOOOOOH!!! *Howl*

                              It's an OO world.

                              public class SanderRossel : Lazy<Person>
                              {
                              public void DoWork()
                              {
                              throw new NotSupportedException();
                              }
                              }

                              J Offline
                              J Offline
                              J Julian
                              wrote on last edited by
                              #34

                              A were-cow????

                              1 Reply Last reply
                              0
                              • Sander RosselS Sander Rossel

                                I'll have my math float away, thank you! :D

                                It's an OO world.

                                public class SanderRossel : Lazy<Person>
                                {
                                public void DoWork()
                                {
                                throw new NotSupportedException();
                                }
                                }

                                J Offline
                                J Offline
                                J Julian
                                wrote on last edited by
                                #35

                                Is that anything like a root beer float?

                                1 Reply Last reply
                                0
                                • E Ennis Ray Lynch Jr

                                  Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                                  Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                                  P Offline
                                  P Offline
                                  patbob
                                  wrote on last edited by
                                  #36

                                  Both. In my experience, when I've needed more than just a few digits of precision, its because I'm doing a complex calculation, and that's usually when I've needed both precision and speed.

                                  We can program with only 1's, but if all you've got are zeros, you've got nothing.

                                  1 Reply Last reply
                                  0
                                  • E Ennis Ray Lynch Jr

                                    Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                                    Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                                    C Offline
                                    C Offline
                                    Colborne_Greg
                                    wrote on last edited by
                                    #37

                                    I would rather use strings, and convert to accurate precision using Unidex.

                                    1 Reply Last reply
                                    0
                                    • E Ennis Ray Lynch Jr

                                      Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                                      Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                                      S Offline
                                      S Offline
                                      ssa ed
                                      wrote on last edited by
                                      #38

                                      A modern 64-bit CPU should be able to do double precision in the exact same time it takes to do single. The only difference is how many bytes (8- 4) are needed to store the answer. Personally, I'd use double precision to the bitter end and then format to any desired width. BTW, my Garmin GPS uses single, but military GPS systems use double for coffee mug precision (a thimble if the antenna would fit) and quad to position (station) satellites.

                                      If you find yourself in a fair fight, your tactics suck. - John Steinbeck

                                      1 Reply Last reply
                                      0
                                      • E enhzflep

                                        Chris Losinger wrote:

                                        i'd love to be able to not have to use 24 bytes per pixel,

                                        er, bits? But, as we all know - palletized images suck when it comes to performing any real manipulation on them, since you're stuck with looking-up the 24 bit values anyway. Alpha-blending images with a pallette? :shudder: Uhhhrgh! Please dont make me do that again. Recomputing a new pallete is more effort than the image processing itself.

                                        U Offline
                                        U Offline
                                        User 10537202
                                        wrote on last edited by
                                        #39

                                        For pallet(e)s, all you need is scrub wood and nails. Palettes on the other hand...

                                        1 Reply Last reply
                                        0
                                        • E Ennis Ray Lynch Jr

                                          Query for all the naysayers ... which would you rather have fast floating point operations or 15 places of accurate precision? Most of my work four places is good enough and I wrote a hurricane damage simulator.

                                          Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. "And they, since they Were not the one dead, turned to their affairs" -- Robert Frost "All users always want Excel" --Ennis Lynch

                                          I Offline
                                          I Offline
                                          irneb
                                          wrote on last edited by
                                          #40

                                          True, in most cases such accuracy is unnecessary and thus just CPU cycles wasted. But there are situations where the accuracy could make for easier accomplishments later. Around 2000 the AutoCAD product changed the way it stored polylines (non regular polygons) - the old way was to save each line/arc segment in series as doubles for XYZ values. This had the detriment that the further you move away from 0,0,0 the worse accuracy became, to the point where such polygon was displayed as dis-joint vectors. The "new" method used a start point, then a length, angle and "bulge" for each vector - made computation a lot faster and the polygon itself didn't loose accuracy because of distance from origin. BUT it has a secondary inaccuracy in that its interaction with other objects became prone to errors - which in turn made things like hatching (fill the space between vectors) very problematic. Anyhow, there are quite a few ways people have tried to get both accuracy as well as speed from these figures. As an example: http://keithbriggs.info/mpfs.html[^] So it seems it's something which just always needs to be chosen on a per-problem basis. Similar to the speed-vs-memory trade-off of using BST / HashTable.

                                          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