in reply to Problems with pack-ing data.

It's not related to pack or BER. It's how floating point numbers work:
#! /usr/bin/perl use warnings; use strict; use feature qw{ say }; my @v = map $_ * 100, 160.22, 160.23; printf "%.20f %d\n", $_, int for @v;
Output:
16022.00000000000000000000 16022 16022.99999999999818101060 16022

See the popular article What Every Programmer Should Know About Floating-Point Arithmetic.

Update: Try the following to see the correct number, too:

printf "%.20f %.0f %d\n", $_, $_, int for @v;
See also round or lround in POSIX.

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re^2: Problems with pack-ing data.
by seann (Novice) on Apr 26, 2021 at 18:18 UTC
    Thanks for your help.

    I added the round function to my pack line:

    pack "w*",map { round $_*100 } @data[$start..$end];

    and the program works as expected now.

      I am quite sure that you will open the article that choroba linked to, declare it 'More than I care to know', and close it immediately. Please do not do that. I recently decided that I had procrastinated long enough and read most of it carefully. I was rewarded with an elegant solution to a problem I first encountered over forty years ago. I wish that I had believed the title when I first encountered this article.
      Bill