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. General Programming
  3. C#
  4. Determine Least Significant Digits

Determine Least Significant Digits

Scheduled Pinned Locked Moved C#
helptutorialquestion
6 Posts 3 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.
  • M Offline
    M Offline
    MumbleB
    wrote on last edited by
    #1

    Hi Guys. I need to know how to determine the least significan't digits from a number. Now, I'm calculating a bunch of numbers and the total comes to say 17 digits in total. I need to only use ythe last significant 12 digits from the 13 digits. HOw do I determine what the least significant digits are? As an example: The calulated value is: 865807311427710 From this number I want to only obtain 807311427710. The problem I am having is that the calculated value can be any amount of digits long. Any help will be greatly appreciated. Thanks

    Excellence is doing ordinary things extraordinarily well.

    OriginalGriffO C 2 Replies Last reply
    0
    • M MumbleB

      Hi Guys. I need to know how to determine the least significan't digits from a number. Now, I'm calculating a bunch of numbers and the total comes to say 17 digits in total. I need to only use ythe last significant 12 digits from the 13 digits. HOw do I determine what the least significant digits are? As an example: The calulated value is: 865807311427710 From this number I want to only obtain 807311427710. The problem I am having is that the calculated value can be any amount of digits long. Any help will be greatly appreciated. Thanks

      Excellence is doing ordinary things extraordinarily well.

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

      Brute force and ingnorance approach: Convert to a string, use substring to get the right hand end.

      No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"

      "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

      M 1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        Brute force and ingnorance approach: Convert to a string, use substring to get the right hand end.

        No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"

        M Offline
        M Offline
        MumbleB
        wrote on last edited by
        #3

        Sounds easy enough but the problem is that I have no idea how long the string will be. It could be 20 digits, 30 digits, 15 digits or 12 digits. :sigh:

        Excellence is doing ordinary things extraordinarily well.

        OriginalGriffO 1 Reply Last reply
        0
        • M MumbleB

          Sounds easy enough but the problem is that I have no idea how long the string will be. It could be 20 digits, 30 digits, 15 digits or 12 digits. :sigh:

          Excellence is doing ordinary things extraordinarily well.

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

          So? Why would you care? number.ToString() doesn't care how long it is. string.Length tells you how long the other one is. You know how many digits you want to keep...

          No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"

          "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

          M 1 Reply Last reply
          0
          • M MumbleB

            Hi Guys. I need to know how to determine the least significan't digits from a number. Now, I'm calculating a bunch of numbers and the total comes to say 17 digits in total. I need to only use ythe last significant 12 digits from the 13 digits. HOw do I determine what the least significant digits are? As an example: The calulated value is: 865807311427710 From this number I want to only obtain 807311427710. The problem I am having is that the calculated value can be any amount of digits long. Any help will be greatly appreciated. Thanks

            Excellence is doing ordinary things extraordinarily well.

            C Offline
            C Offline
            Covean
            wrote on last edited by
            #5

            How about long lDigits = lCalulatedVal % 1000000000000; this should do the trick.

            Greetings Covean

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              So? Why would you care? number.ToString() doesn't care how long it is. string.Length tells you how long the other one is. You know how many digits you want to keep...

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones "Rumour has it that if you play Microsoft CDs backwards you will hear Satanic messages.Worse still, is that if you play them forwards they will install Windows"

              M Offline
              M Offline
              MumbleB
              wrote on last edited by
              #6

              Aye, I got it. Below is what I have done.

                                  FinalHash = homingTotal + OverFlow + ContraHash;
                                  string hashfinal = Convert.ToString(FinalHash);
                                  int length = hashfinal.Length;
                                  int remove = length - 12;
                                  outhash = hashfinal.Substring(remove, 12);
                                  finalhashtotal = Convert.ToInt64(outhash);
              

              Excellence is doing ordinary things extraordinarily well.

              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