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. MILLISEC_PER_SEC is never needed

MILLISEC_PER_SEC is never needed

Scheduled Pinned Locked Moved The Lounge
76 Posts 31 Posters 4 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.
  • Richard DeemingR Richard Deeming

    Or the simpler option: 0.0833 (Assuming the hamsters don't eat the style.)


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    D Offline
    D Offline
    David Crow
    wrote on last edited by
    #37

    Yeah, overline works too.

    "One man's wage rise is another man's price increase." - Harold Wilson

    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

    "You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles

    1 Reply Last reply
    0
    • C Chris Maunder

      It depends if you measure them or not.

      cheers Chris Maunder

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #38

      I can't be bothered with such fiddling small change.

      1 Reply Last reply
      0
      • C Chris Maunder

        Must...refrain...from...New Zealand...joke....

        cheers Chris Maunder

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #39

        Oh please !!! DO IT!

        I'd rather be phishing!

        1 Reply Last reply
        0
        • C Chris Maunder

          C'mon - quatre vingt dix rolls off the tongue! (and it's the reason I can only count to 69 in French when I'm drunk. The maths gets too hard)

          cheers Chris Maunder

          J Offline
          J Offline
          Jorgen Andersson
          wrote on last edited by
          #40

          It's easier in Switzerland, they use septante, octante, nonante instead of soixante-dix, quatre-vingts, quatre-vingt-dix. In Belgium they use some bastardised version with septante, quatre-vingt, nonante IIRC.

          Wrong is evil and must be defeated. - Jeff Ello

          1 Reply Last reply
          0
          • J Jochen Arndt

            Eddy Vluggen wrote:

            It's also a nice shortcut, to change the display from msec to sec, just by setting this constant to "0" instead of "1000" :p

            Depending on the usage you might then get a "Division by zero" exception / fatal error popup window instead.

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

            Call it a feature? ;P

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

            1 Reply Last reply
            0
            • C Chris Maunder

              I put it to you that a variable, constant or define named "MILLISEC_PER_SEC" is never, ever, ever needed.

              cheers Chris Maunder

              D Offline
              D Offline
              David ONeil
              wrote on last edited by
              #42

              Relatively speaking, without it, how could you ever know that your MILLISEC_PER_SEC doesn't match mine? :|

              The forgotten roots of science | C++ Programming | DWinLib

              1 Reply Last reply
              0
              • C Chris Maunder

                I put it to you that a variable, constant or define named "MILLISEC_PER_SEC" is never, ever, ever needed.

                cheers Chris Maunder

                J Offline
                J Offline
                Joe Woodbury
                wrote on last edited by
                #43

                I actually disagree; I often deal with code using second, milliseconds, microseconds and even nanoseconds, sometimes with more than one unit in a function. Having a const (of some sort) declares what conversion was intended.

                C 1 Reply Last reply
                0
                • C Chris Maunder

                  I put it to you that a variable, constant or define named "MILLISEC_PER_SEC" is never, ever, ever needed.

                  cheers Chris Maunder

                  S Offline
                  S Offline
                  Super Lloyd
                  wrote on last edited by
                  #44

                  But what about ONE_SECOND_MS ?

                  A new .NET Serializer All in one Menu-Ribbon Bar Taking over the world since 1371!

                  1 Reply Last reply
                  0
                  • P PIEBALDconsult

                    Surely that's a constant?

                    K Offline
                    K Offline
                    kalberts
                    wrote on last edited by
                    #45

                    Constants ain't. Variables won't.

                    1 Reply Last reply
                    0
                    • C Chris Maunder

                      I put it to you that a variable, constant or define named "MILLISEC_PER_SEC" is never, ever, ever needed.

                      cheers Chris Maunder

                      K Offline
                      K Offline
                      kalberts
                      wrote on last edited by
                      #46

                      But you wouldn't believe how many people talk about 'kWh per hour' Sure, it could be meaningful if the power varies, but then 'kWh per hour' might vary, too, and cannot be treated as a single value. And lots of people refer to kWh/hour even when the power is constant.

                      C 1 Reply Last reply
                      0
                      • C Chris Maunder

                        I put it to you that a variable, constant or define named "MILLISEC_PER_SEC" is never, ever, ever needed.

                        cheers Chris Maunder

                        K Offline
                        K Offline
                        kalberts
                        wrote on last edited by
                        #47

                        But we really need a constant - or is that a variable? - ZEROES_IN_ONE_BILLION.

                        P C 2 Replies Last reply
                        0
                        • W W Balboos GHB

                          Or, perhaps it's needed to differentiate in regions where they use an Imperial Second instead of a regular one.

                          Ravings en masse^

                          "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                          "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #48

                          Like a dueling second?

                          1 Reply Last reply
                          0
                          • K kalberts

                            But we really need a constant - or is that a variable? - ZEROES_IN_ONE_BILLION.

                            P Offline
                            P Offline
                            PIEBALDconsult
                            wrote on last edited by
                            #49

                            Is that a leading question?

                            K 1 Reply Last reply
                            0
                            • P PIEBALDconsult

                              Is that a leading question?

                              K Offline
                              K Offline
                              kalberts
                              wrote on last edited by
                              #50

                              Consider it as a "Constants ain't, varaiables won't" sample.

                              P 1 Reply Last reply
                              0
                              • K kalberts

                                Consider it as a "Constants ain't, varaiables won't" sample.

                                P Offline
                                P Offline
                                PIEBALDconsult
                                wrote on last edited by
                                #51

                                I suppose that's the long and short of it.

                                1 Reply Last reply
                                0
                                • J Joe Woodbury

                                  I actually disagree; I often deal with code using second, milliseconds, microseconds and even nanoseconds, sometimes with more than one unit in a function. Having a const (of some sort) declares what conversion was intended.

                                  C Offline
                                  C Offline
                                  Chris Maunder
                                  wrote on last edited by
                                  #52

                                  A counterargument. Excellent. My counter-counter argument, and the reason my brain popped: I would always prefer to have something like

                                  var timeInSeconds = X;
                                  var timeInMilliseconds = timeInSeconds / 1000;

                                  My point is that the 1000 is always 1000. The variables surrounding that should be the ones clearly named. The "1000" can never be anything other than 1000. At least that's what I think.

                                  cheers Chris Maunder

                                  J K 2 Replies Last reply
                                  0
                                  • K kalberts

                                    But you wouldn't believe how many people talk about 'kWh per hour' Sure, it could be meaningful if the power varies, but then 'kWh per hour' might vary, too, and cannot be treated as a single value. And lots of people refer to kWh/hour even when the power is constant.

                                    C Offline
                                    C Offline
                                    Chris Maunder
                                    wrote on last edited by
                                    #53

                                    So: What if you then had

                                    var kiloWattPerHourPerHour = X;
                                    var kiloWattPerHourPerMinute = kiloWattPerHourPerHour / 60;

                                    Should the 60 be a constant or a literal?

                                    cheers Chris Maunder

                                    K 1 Reply Last reply
                                    0
                                    • C Chris Maunder

                                      A counterargument. Excellent. My counter-counter argument, and the reason my brain popped: I would always prefer to have something like

                                      var timeInSeconds = X;
                                      var timeInMilliseconds = timeInSeconds / 1000;

                                      My point is that the 1000 is always 1000. The variables surrounding that should be the ones clearly named. The "1000" can never be anything other than 1000. At least that's what I think.

                                      cheers Chris Maunder

                                      J Offline
                                      J Offline
                                      Joe Woodbury
                                      wrote on last edited by
                                      #54

                                      Aaaaggghhhh, Magic Number..... "It's supposed to be microseconds? Shit." (Near accurate quote.)

                                      C 1 Reply Last reply
                                      0
                                      • K kalberts

                                        But we really need a constant - or is that a variable? - ZEROES_IN_ONE_BILLION.

                                        C Offline
                                        C Offline
                                        Chris Maunder
                                        wrote on last edited by
                                        #55

                                        I blame the Brits for that one.

                                        cheers Chris Maunder

                                        J 1 Reply Last reply
                                        0
                                        • J Joe Woodbury

                                          Aaaaggghhhh, Magic Number..... "It's supposed to be microseconds? Shit." (Near accurate quote.)

                                          C Offline
                                          C Offline
                                          Chris Maunder
                                          wrote on last edited by
                                          #56

                                          <small pause> OK. That argument I will accept in that the number may appear in more than one place, making refactoring painful. Except, except, except: the calculation should only be done in one place:

                                          var variable = ConvertToMilliFurlongs(X);

                                          ...

                                          function ConvertToMilliFurlongs(furlongs)
                                          {
                                          return furlongs / 1000;
                                          }

                                          So if it's "Dammit, Janet. It should be microFurlongs" then you rename ConvertToMilliFurlongs to ConvertToMicroFurlongs and change the 1000 to 1000000. Everything's still clear.

                                          cheers Chris Maunder

                                          J 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