本文整理汇总了PHP中Math::abs方法的典型用法代码示例。如果您正苦于以下问题:PHP Math::abs方法的具体用法?PHP Math::abs怎么用?PHP Math::abs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Math
的用法示例。
在下文中一共展示了Math::abs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_hash
static function do_hash($s)
{
$b = 378551;
$a = 63689;
$hash = 0;
$i = 0;
$_g1 = 0;
$_g = strlen($s);
while ($_g1 < $_g) {
$i1 = $_g1++;
$hash = $hash * $a + _hx_char_code_at($s, $i1);
$a = $a * $b;
unset($i1);
}
return Math::abs($hash);
}
示例2: getMoonTimes
static function getMoonTimes($date, $lat, $lng, $inUTC = null)
{
if ($inUTC === null) {
$inUTC = false;
}
if ($inUTC) {
$this1 = datetime__DateTime_DateTime_Impl_::utc(suncalc_SunCalc_0($date, $inUTC, $lat, $lng));
$date = Date::fromTime(($this1 - 62135596800.0) * 1000);
$date = new Date($date->getFullYear(), $date->getMonth(), $date->getDate(), 0, 0, 0);
} else {
$date = new Date($date->getFullYear(), $date->getMonth(), $date->getDate(), 0, 0, 0);
}
$hc = 0.133 * suncalc_SunCalc::$rad;
$h0 = suncalc_SunCalc::getMoonPosition($date, $lat, $lng)->altitude - $hc;
$h1 = null;
$h2 = null;
$rise = 0.0;
$set = 0.0;
$a = null;
$b = null;
$xe = null;
$ye = 0.0;
$d = null;
$roots = null;
$x1 = 0.0;
$x2 = 0.0;
$dx = null;
$i = 1;
while ($i <= 24) {
$h1 = suncalc_SunCalc::getMoonPosition(suncalc_SunCalc::hoursLater($date, $i), $lat, $lng)->altitude - $hc;
$h2 = suncalc_SunCalc::getMoonPosition(suncalc_SunCalc::hoursLater($date, $i + 1), $lat, $lng)->altitude - $hc;
$a = ($h0 + $h2) / 2 - $h1;
$b = ($h2 - $h0) / 2;
$xe = -$b / (2 * $a);
$ye = ($a * $xe + $b) * $xe + $h1;
$d = $b * $b - 4 * $a * $h1;
$roots = 0;
if ($d >= 0) {
$dx = Math::sqrt($d) / (Math::abs($a) * 2);
$x1 = $xe - $dx;
$x2 = $xe + $dx;
if (Math::abs($x1) <= 1) {
$roots++;
}
if (Math::abs($x2) <= 1) {
$roots++;
}
if ($x1 < -1) {
$x1 = $x2;
}
}
if ($roots === 1) {
if ($h0 < 0) {
$rise = $i + $x1;
} else {
$set = $i + $x1;
}
} else {
if ($roots === 2) {
$rise = $i + ($ye < 0 ? $x2 : $x1);
$set = $i + ($ye < 0 ? $x1 : $x2);
}
}
if (!_hx_equal($rise, 0) && !_hx_equal($set, 0)) {
break;
}
$h0 = $h2;
$i += 2;
}
$result = new haxe_ds_StringMap();
if (!_hx_equal($rise, 0)) {
$v = suncalc_SunCalc::hoursLater($date, $rise);
$result->set("rise", $v);
$v;
}
if (!_hx_equal($set, 0)) {
$v1 = suncalc_SunCalc::hoursLater($date, $set);
$result->set("set", $v1);
$v1;
}
if (_hx_equal($rise, 0) && _hx_equal($set, 0)) {
$result->set($ye > 0 ? "alwaysUp" : "alwaysDown", true);
true;
}
return $result;
}