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

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!

Replies are listed 'Best First'.
Re^3: How to pack and unpack 16 bit decimal with leading zero
by BrowserUk (Patriarch) on Jul 27, 2015 at 10:47 UTC
    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!