<commit_before>package Math::Roundeth;
use strict;
use warnings;
use POSIX;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

require Exporter;

@ISA = qw(Exporter AutoLoader);
@EXPORT = qw(round nearest);
@EXPORT_OK = qw(round nearest );
$VERSION = '666';

%EXPORT_TAGS = ( all => [ @EXPORT_OK ] );

#--- Default value for "one-half". This is the lowest value that
#--- gives acceptable results for test #6 in test.pl. See the pod
#--- for more information.

$Math::Roundeth::half = 0.50000000000008;

sub round {
 my $x;
 my @res  = map {
  if ($_ >= 0) { POSIX::floor($_ + $Math::Roundeth::half); }
     else { POSIX::ceil($_ - $Math::Roundeth::half); }
 } @_;

 return (wantarray) ? @res : $res[0];
}

#------ "Nearest" routines (round to a multiple of any number)

sub nearest {
 my $targ = abs(shift);
 my @res  = map {
  if ($_ >= 0) { $targ * int(($_ + $Math::Roundeth::half * $targ) / $targ); }
     else { $targ * POSIX::ceil(($_ - $Math::Roundeth::half * $targ) / $targ); }
 } @_;

 return (wantarray) ? @res : $res[0];
}



1;
<commit_msg>fixing Math::Roundeth::nearest to apparently<commit_after>package Math::Roundeth;
use strict;
use warnings;
use POSIX;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);

require Exporter;

@ISA = qw(Exporter AutoLoader);
@EXPORT = qw(round nearest);
@EXPORT_OK = qw(round nearest );
$VERSION = '666';

%EXPORT_TAGS = ( all => [ @EXPORT_OK ] );

#--- Default value for "one-half". This is the lowest value that
#--- gives acceptable results for test #6 in test.pl. See the pod
#--- for more information.

$Math::Roundeth::half = 0.50000000000008;

sub round {
 my $x;
 my @res  = map {
  if ($_ >= 0) { POSIX::floor($_ + $Math::Roundeth::half); }
     else { POSIX::ceil($_ - $Math::Roundeth::half); }
 } @_;

 return (wantarray) ? @res : $res[0];
}

#------ "Nearest" routines (round to a multiple of any number)

sub nearest {
 my $targ = abs(shift);
 my @res  = map {
  if ($_ >= 0) { $targ * int(($_ + $Math::Roundeth::half * $targ) / $targ); }
     else { $targ * POSIX::ceil(($_ - $Math::Roundeth::half * $targ) / $targ); }
 } @_;

 @res = map{"$_"} @res;
 # without this string conversion, .35 != nearest(.01,.35)
 # That may still be the case depending on how your platform handles things.

 return (wantarray) ? @res : $res[0];
}



1;

{'fraction_non_alphanumeric': 0.19127806563039723, 'fraction_numerical': 0.023316062176165803, 'mean_word_length': 3.709349593495935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '768681', 'n_tokens_mistral': 907, 'n_tokens_neox': 835, 'n_words': 245}