in reply to [SOLVED] How to pack and unpack 16 bit decimal with leading zero

Is there any point in asking you why you feel the need to retain the leading zero?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
  • Comment on Re: How to pack and unpack 16 bit decimal with leading zero

Replies are listed 'Best First'.
Re^2: How to pack and unpack 16 bit decimal with leading zero
by thanos1983 (Parson) on Jul 27, 2015 at 10:42 UTC

    Hello BrowserUk,

    Thank you for your time and effort, reading and replying to my question.

    Well the reason that I need to have a leading zero, is that the number is a decimal. I am getting this value and then I split the decimal to the main and the remaining part. So the main usually is 0 or 1 maybe in worst cases two digit number. The remaining number usually is like (0.0124). Usually it contains a leading zero, but in some cases it does not.

    This is the reason that I need to have a leading zero, on the number.

    Thank you for your time and effort reading and replying to my question.

    Seeking for Perl wisdom...on the process of learning...not there...yet!
      the reason that I need to have a leading zero, is that the number is a decimal. I am getting this value and then I split the decimal to the main and the remaining part

      Then why are you splitting it into two parts?

      Why not pack it as a floating point value: my $packed = pack 'f', 1.0124;?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
      I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!