THZ: fixed warning ::Round::half

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@9087 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
immiimmi
2015-08-17 19:41:09 +00:00
parent c83fffca85
commit 7ca6f0bee0

View File

@@ -2,7 +2,7 @@
# 00_THZ
# $Id$
# 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
# 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_ceil(10, 44); --> 40
# nearest_floor(10, 44); --> 50
# nearest_ceil(10, 45); --> 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
########################################################################################
sub nearest_ceil {
sub nearest_ceil($$) {
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];
}
sub nearest_floor {
sub nearest_floor($$) {
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];
}