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. Other Discussions
  3. The Weird and The Wonderful
  4. When the CEO becomes a developer II

When the CEO becomes a developer II

Scheduled Pinned Locked Moved The Weird and The Wonderful
databasemysqlquestionannouncement
16 Posts 10 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.
  • N Nagy Vilmos

    imagiro wrote:

    $time=time()+ 365*24*60*60;

    Does nobody know that there are 86,400 seconds ina day? [I can't prove this but I have thios ingrained in my long-term memory.]


    Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

    P Offline
    P Offline
    Peter_in_2780
    wrote on last edited by
    #7

    Distant memories of childhood wonderment: Eight six four two zero(es). And yes, it has been useful these last 60-odd years. Cheers, Peter ps No idea why you got downvoted. Have my 5 in at least partial compensation.

    Software rusts. Simon Stephenson, ca 1994.

    1 Reply Last reply
    0
    • N Nagy Vilmos

      imagiro wrote:

      $time=time()+ 365*24*60*60;

      Does nobody know that there are 86,400 seconds ina day? [I can't prove this but I have thios ingrained in my long-term memory.]


      Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

      C Offline
      C Offline
      Charvak Karpe
      wrote on last edited by
      #8

      Nagy Vilmos wrote:

      Does nobody know that there are 86,400 seconds ina day? [I can't prove this but I have thios ingrained in my long-term memory.]

      Just last week I wrote a formula that included "numdays * 86400" and then I replaced it with "numdays * 24 * 60 * 60" because that adds clarity for the people who don't know how many seconds are in a day. If other people are going to read your code, it's easier to do 24*60*60 than to add a comment explaining why you're multiplying by 86400.

      D D 2 Replies Last reply
      0
      • C Charvak Karpe

        Nagy Vilmos wrote:

        Does nobody know that there are 86,400 seconds ina day? [I can't prove this but I have thios ingrained in my long-term memory.]

        Just last week I wrote a formula that included "numdays * 86400" and then I replaced it with "numdays * 24 * 60 * 60" because that adds clarity for the people who don't know how many seconds are in a day. If other people are going to read your code, it's easier to do 24*60*60 than to add a comment explaining why you're multiplying by 86400.

        D Offline
        D Offline
        djdanlib 0
        wrote on last edited by
        #9

        Indeed. Your compiler should do that multiplication as part of the optimization stage anyway, so feel free to leave arithmetic on constants like that in your code as long as it improves the situation. Even if it didn't optimize that out, if you're waiting on the SQL server to retrieve your results like that, the last thing you'll notice is 2 extra integer multiplication operations.

        1 Reply Last reply
        0
        • N Nagy Vilmos

          imagiro wrote:

          $time=time()+ 365*24*60*60;

          Does nobody know that there are 86,400 seconds ina day? [I can't prove this but I have thios ingrained in my long-term memory.]


          Panic, Chaos, Destruction. My work here is done. or "Drink. Get drunk. Fall over." - P O'H

          A Offline
          A Offline
          AspDotNetDev
          wrote on last edited by
          #10

          I didn't, but for some reason I know there are 525,600 minutes in a year. :rolleyes:

          [Forum Guidelines]

          P 1 Reply Last reply
          0
          • A AspDotNetDev

            I didn't, but for some reason I know there are 525,600 minutes in a year. :rolleyes:

            [Forum Guidelines]

            P Offline
            P Offline
            Peter_in_2780
            wrote on last edited by
            #11

            A workable "slide rule" approximation: 1 year = 10^7.5 seconds. [A leap year is even closer! ;P ]

            Software rusts. Simon Stephenson, ca 1994.

            A 1 Reply Last reply
            0
            • P Peter_in_2780

              A workable "slide rule" approximation: 1 year = 10^7.5 seconds. [A leap year is even closer! ;P ]

              Software rusts. Simon Stephenson, ca 1994.

              A Offline
              A Offline
              AspDotNetDev
              wrote on last edited by
              #12

              I guess now we know how you measure a year. :)

              [Forum Guidelines]

              P 1 Reply Last reply
              0
              • A AspDotNetDev

                I guess now we know how you measure a year. :)

                [Forum Guidelines]

                P Offline
                P Offline
                Peter_in_2780
                wrote on last edited by
                #13

                All is revealed! From the "Eight Days a Week" school of mathematical chronology. :laugh: :laugh:

                Software rusts. Simon Stephenson, ca 1994.

                1 Reply Last reply
                0
                • C Charvak Karpe

                  Nagy Vilmos wrote:

                  Does nobody know that there are 86,400 seconds ina day? [I can't prove this but I have thios ingrained in my long-term memory.]

                  Just last week I wrote a formula that included "numdays * 86400" and then I replaced it with "numdays * 24 * 60 * 60" because that adds clarity for the people who don't know how many seconds are in a day. If other people are going to read your code, it's easier to do 24*60*60 than to add a comment explaining why you're multiplying by 86400.

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #14

                  Wow. So you replaced a "magic number" with a set of "magic numbers" for clarity? Replace the thing with a constant and you'd be doing far, far better.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  C 1 Reply Last reply
                  0
                  • D Dave Kreskowiak

                    Wow. So you replaced a "magic number" with a set of "magic numbers" for clarity? Replace the thing with a constant and you'd be doing far, far better.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak

                    C Offline
                    C Offline
                    Charvak Karpe
                    wrote on last edited by
                    #15

                    #define SECONDS_IN_A_DAY 86400 is clearer and slightly educational to the reader, so definitely a better solution You trivialize my approach as using "magic numbers", but in the real world probably 90% of the population can tell what you're doing if you do 24 * 60 * 60 whilst maybe 15% of people know what 86400 is. So, I'd still say 24 * 60 * 60 is clearer than 86400 despite it being 3 "magic numbers" instead of 1. Astonishingly, if you add a fourth magic number, nearly every literate human on the Western calendar understands it with no explanation: "365 * 24 * 60 * 60".

                    D 1 Reply Last reply
                    0
                    • C Charvak Karpe

                      #define SECONDS_IN_A_DAY 86400 is clearer and slightly educational to the reader, so definitely a better solution You trivialize my approach as using "magic numbers", but in the real world probably 90% of the population can tell what you're doing if you do 24 * 60 * 60 whilst maybe 15% of people know what 86400 is. So, I'd still say 24 * 60 * 60 is clearer than 86400 despite it being 3 "magic numbers" instead of 1. Astonishingly, if you add a fourth magic number, nearly every literate human on the Western calendar understands it with no explanation: "365 * 24 * 60 * 60".

                      D Offline
                      D Offline
                      Dave Kreskowiak
                      wrote on last edited by
                      #16

                      Charvak Karpe wrote:

                      but in the real world probably 90% of the population can tell what you're doing if you do 24 * 60 * 60

                      You haven't worked with some of the developers I work with now. No, they couldn't tell you what that code was doing... seriously.

                      A guide to posting questions on CodeProject[^]
                      Dave Kreskowiak

                      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