2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-03-04 11:26:55 +00:00

THZ: fixed warning ::Round::half

git-svn-id: https://svn.fhem.de/fhem/trunk@9087 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
immiimmi 2015-08-17 19:41:09 +00:00
parent dbefe732f6
commit eac0c17903

View File

@ -2,7 +2,7 @@
# 00_THZ # 00_THZ
# $Id$ # $Id$
# by immi 04/2015 # by immi 04/2015
my $thzversion = "0.143"; my $thzversion = "0.144";
# this code is based on the hard work of Robert; I just tried to port it # this code is based on the hard work of Robert; I just tried to port it
# http://robert.penz.name/heat-pump-lwz/ # http://robert.penz.name/heat-pump-lwz/
######################################################################################## ########################################################################################
@ -1596,22 +1596,25 @@ sub THZ_Undef($$) {
########################################## ##########################################
# nearest rounds to the nearrest value multiple of the first argumen # nearest rounds to the nearrest value multiple of the first argumen
# nearest_ceil(10, 44); --> 40 # nearest_ceil(10, 45); --> 50
# nearest_floor(10, 44); --> 50 # nearest_floor(10, 45); --> 40
# for all other values outside the middlevalues they take he nearest
# modified takes as an argument the function to be called, not the argument # modified takes as an argument the function to be called, not the argument
######################################################################################## ########################################################################################
sub nearest_ceil { sub nearest_ceil($$) {
my $targ = abs(shift); my $targ = abs(shift);
my @res = map { $targ * POSIX::floor(($_ + $Math::Round::half * $targ) / $targ) } @_; my $Math1 = 0.5000000000003;
my @res = map { $targ * POSIX::floor(($_ + $Math1 * $targ) / $targ) } @_;
return wantarray ? @res : $res[0]; return wantarray ? @res : $res[0];
} }
sub nearest_floor { sub nearest_floor($$) {
my $targ = abs(shift); my $targ = abs(shift);
my @res = map { $targ * POSIX::ceil(($_ - $Math::Round::half * $targ) / $targ) } @_; my $Math1 = 0.5000000000003;
my @res = map { $targ * POSIX::ceil(($_ - $Math1 * $targ) / $targ) } @_;
return wantarray ? @res : $res[0]; return wantarray ? @res : $res[0];
} }