本文整理汇总了PHP中is_nan函数的典型用法代码示例。如果您正苦于以下问题:PHP is_nan函数的具体用法?PHP is_nan怎么用?PHP is_nan使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_nan函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: view_non_approve
function view_non_approve()
{
$page = $this->input->get('page');
if ($page == NULL || is_nan($page)) {
$page = 1;
}
// get non-approved dealers
$q = array('dealer_level_id' => 0);
$lim = 15;
$off = $lim * $page - $lim;
$dealers = $this->Dealer->list_dealers($q, $lim, $off, 'obj', 'dealer_datetime DESC , dealer_id DESC');
$rows = $this->Dealer->get_num_rows($q);
$page_amount = 1;
if ($rows % $lim == 0 || $rows % $lim == $lim) {
$page_amount = $rows / $lim;
} else {
$page_amount = $rows / $lim + 1;
}
$data['dealers'] = $dealers;
$data['rows'] = $dealers;
$data['off'] = $off;
$data['pa'] = (int) $page_amount;
$data['page'] = $page;
//load view
$this->load->view('admin_v/waitApprove', $data);
}
开发者ID:M4A1Predator,项目名称:dealer_system,代码行数:26,代码来源:Dealer_set.php
示例2: fromDouble
private static function fromDouble($value)
{
if (is_nan($value)) {
return 0;
}
if ($value < -self::TWO_PWR_63_DBL) {
return Long::MIN_VALUE;
}
if ($value >= self::TWO_PWR_63_DBL) {
return Long::MAX_VALUE;
}
$negative = false;
if ($value < 0) {
$negative = true;
$value = -$value;
}
$a2 = 0;
if ($value >= self::TWO_PWR_44_DBL) {
$a2 = (int) ($value / self::TWO_PWR_44_DBL);
$value -= $a2 * self::TWO_PWR_44_DBL;
}
$a1 = 0;
if ($value >= self::TWO_PWR_22_DBL) {
$a1 = (int) ($value / self::TWO_PWR_22_DBL);
$value -= $a1 * self::TWO_PWR_22_DBL;
}
$a0 = (int) $value;
$result = $a2 << 44 | $a1 << 22 | $a0;
if ($negative) {
$result = -$result;
}
return $result;
}
开发者ID:google-code-backups,项目名称:gwtphp-derpc,代码行数:33,代码来源:ServerSerializationStream.php
示例3: find
public function find($n)
{
if (isset($n) && !is_nan($n)) {
$n = intval($n);
$query = ' SELECT *
FROM message
ORDER BY rate DESC
LIMIT ' . $n;
} else {
$query = ' SELECT *
FROM message
ORDER BY rate DESC';
}
$res = $this->db->query($query);
if ($res) {
$messages = $res->fetchAll(PDO::FETCH_CLASS, "Message", array($this->db));
if (count($messages) > 0) {
return $messages;
} else {
throw new Exception('No message to show');
}
} else {
throw new Exception('Error 01 : Database error');
}
}
开发者ID:berserkr1,项目名称:e-commerce,代码行数:25,代码来源:MessageManager.class.php
示例4: encode
public static function encode($input)
{
$output = "";
$chr1 = $chr2 = $chr3 = $enc1 = $enc2 = $enc3 = $enc4 = "";
$i = 0;
$input = self::utf8_encode($input);
while ($i < mb_strlen($input)) {
$chr1 = Z_Unicode::charCodeAt($input, $i++);
$chr2 = Z_Unicode::charCodeAt($input, $i++);
$chr3 = Z_Unicode::charCodeAt($input, $i++);
$enc1 = $chr1 >> 2;
$enc2 = ($chr1 & 3) << 4 | $chr2 >> 4;
$enc3 = ($chr2 & 15) << 2 | $chr3 >> 6;
$enc4 = $chr3 & 63;
if (is_nan($chr2)) {
$enc3 = $enc4 = 64;
} else {
if (is_nan($chr3)) {
$enc4 = 64;
}
}
$output = $output . Z_Unicode::charAt(self::$keyStr, $enc1) . Z_Unicode::charAt(self::$keyStr, $enc2) . Z_Unicode::charAt(self::$keyStr, $enc3) . Z_Unicode::charAt(self::$keyStr, $enc4);
}
return $output;
}
开发者ID:selenus,项目名称:dataserver,代码行数:25,代码来源:Base64.inc.php
示例5: handleSpeed
function handleSpeed($link, $devid, $lat, $long)
{
// Find previous location event for devid
$res = mysql_query("SELECT statusCode,timestamp,latitude,longitude FROM EventData WHERE (deviceID='" . $devid . "' AND statusCode=61472) ORDER BY timestamp DESC LIMIT 1", $link);
// If there is a previous location
if (mysql_num_rows($res) > 0) {
list($statusCode, $lasttime, $lastlat, $lastlong) = mysql_fetch_row($res);
// get time diff
$deltatime = time() - $lasttime;
// calculate heading and speed
$heading = calculateBearing($lastlat, $lastlong, $lat, $long);
if (is_nan($heading)) {
$heading = 0;
}
$speed = calculateSpeed($lastlat, $lastlong, $lat, $long, $deltatime);
if (is_nan($speed)) {
$speed = 0;
}
$retval = array($speed, $heading);
}
if (isset($retval)) {
return $retval;
} else {
return array(0, 0);
}
}
开发者ID:aldridged,项目名称:gtg-gts,代码行数:26,代码来源:datapump.php
示例6: base64_encode
public function base64_encode($input)
{
$output = "";
$chr1 = $chr2 = $chr3 = $enc1 = $enc2 = $enc3 = $enc4 = null;
$i = 0;
// $input = self::utf8_encode($input);
while ($i < strlen($input)) {
$chr1 = ord($input[$i++]);
$chr2 = ord($input[$i++]);
$chr3 = ord($input[$i++]);
$enc1 = $chr1 >> 2;
$enc2 = ($chr1 & 3) << 4 | $chr2 >> 4;
$enc3 = ($chr2 & 15) << 2 | $chr3 >> 6;
$enc4 = $chr3 & 63;
if (is_nan($chr2)) {
$enc3 = $enc4 = 64;
} else {
if (is_nan($chr3)) {
$enc4 = 64;
}
}
$output .= self::$BinaryMap[$enc1] . self::$BinaryMap[$enc2] . self::$BinaryMap[$enc3] . self::$BinaryMap[$enc4];
}
return $output;
}
开发者ID:nirnanaaa,项目名称:xlix,代码行数:25,代码来源:Base64.php
示例7: toInteger
/**
* 与えられた値を整数型に変換して返します。
* @link http://www.hcn.zaq.ne.jp/___/WEB/WebIDL-ja.html#es-integers Web IDL (第2版 — 日本語訳)
* @param boolean|integer|float|string|resource|\GMP|\SplInt $value
* @param string $type byte、octet、short、unsigned short、long、unsigned long、long long、unsigned long long
* @param integer|float $min 浮動小数点型で正確に扱える整数の範囲よりも、整数型で扱える整数の範囲が狭ければ (整数型が32bitである環境なら) 浮動小数点数。
* @param integer|float $max 浮動小数点型で正確に扱える整数の範囲よりも、整数型で扱える整数の範囲が狭ければ (整数型が32bitである環境なら) 浮動小数点数。
* @param integer $bits
* @param booelan $signed
* @param string $extendedAttribute 拡張属性。[EnforceRange] か [Clamp] のいずれか。
* @return integer|float 整数型の範囲を超える場合は浮動小数点数。
* @throws \InvalidArgumentException 配列、NULL が与えられた場合。または、GMP、SplInt 以外のオブジェクトが与えられた場合。
* @throws \DomainException $extendedAttribute が [EnforceRange]、かつ与えられたの値が $min 〜 $max に収まらなかった場合。
*/
private static function toInteger($value, $type, $min, $max, $bits, $signed, $extendedAttribute = null)
{
/** @var string 要求される型。 */
$expectedType = sprintf('%s (an integer in the range of %s to %s)', $type, is_float($min) ? number_format($min, 0, '', '') : $min, is_float($max) ? number_format($max, 0, '', '') : $max);
if (!self::isIntegerCastable($value)) {
throw new \InvalidArgumentException(ErrorMessageCreator::create($value, $expectedType));
}
if ($value instanceof \GMP || is_resource($value) && get_resource_type($value) === 'GMP integer') {
// GMP数であれば、あらかじめ文字列に変換しておく
$value = gmp_strval($value);
}
/** @var integer|float 与えられた値の数値表現。整数型の範囲を超える場合は浮動小数点数。整数値となる場合、小数部があれば0方向へ丸められる。 */
$number = is_float($value) || (double) $value < self::$phpIntMin || (double) $value > PHP_INT_MAX ? (double) $value : (int) $value;
if ($extendedAttribute === '[EnforceRange]') {
/** @var integer|float 与えられた値の整数表現。整数型の範囲を超える場合は浮動小数点数。 */
$integer = self::roundTowardZero($number);
if (!is_finite($number) || $integer < $min || $integer > $max) {
throw new \DomainException(ErrorMessageCreator::create($value, $expectedType));
}
} elseif (!is_nan($number) && $extendedAttribute === '[Clamp]') {
$number = min(max($number, $min), $max);
$integer = is_float($number) ? round($number, 0, PHP_ROUND_HALF_EVEN) : $number;
} elseif (!is_finite($number)) {
$integer = 0;
} else {
$integer = self::modulo(self::roundTowardZero($number), pow(2, $bits));
if ($signed && $integer >= pow(2, $bits - 1)) {
$integer -= pow(2, $bits);
}
}
return is_float($integer) && $integer >= self::$phpIntMin && $integer <= PHP_INT_MAX ? (int) $integer : $integer;
}
开发者ID:esperecyan,项目名称:webidl,代码行数:46,代码来源:IntegerType.php
示例8: view_payments
function view_payments()
{
$status = $this->input->get('st');
$page = $this->input->get('page');
if ($page == NULL || $page == '' || is_nan($page)) {
$page = 1;
}
$p_arr = array();
//ftilter
if ($status != NULL && is_numeric($status)) {
$p_arr['order_order_status_id'] = $status;
} else {
$status = "";
}
$off = $this->lim * $page - $this->lim;
$rows = $this->Payment->get_num_rows($p_arr);
if ($rows % $this->lim == 0 || $rows % $this->lim == $this->lim) {
$page_amount = $rows / $this->lim;
} else {
$page_amount = $rows / $this->lim + 1;
}
$payments = $this->Payment->list_payments($p_arr, $this->lim, $off, 'obj');
$sts = $this->Order_status->list_order_status();
$data['payments'] = $payments;
$data['sts'] = $sts;
$data['osid'] = $status;
$data['page_amount'] = $page_amount;
$data['page'] = $page;
$data['rows'] = $rows;
$data['off'] = $off;
$this->load->view('admin_v/allPayment', $data);
}
开发者ID:M4A1Predator,项目名称:dealer_system,代码行数:32,代码来源:Payment_set.php
示例9: getTodaysTotal
/**
* Get the total amount of money raised for today
* @param string $timeZoneOffset The timezone to request the total for
* @param string $today The current date in the requested time zone, e.g. '2011-12-16'
* @param int $fudgeFactor How much to adjust the total by
* @return integer
*/
private function getTodaysTotal($timeZoneOffset, $today, $fudgeFactor = 0)
{
global $wgMemc, $egFundraiserStatisticsMinimum, $egFundraiserStatisticsMaximum, $egFundraiserStatisticsCacheTimeout;
// Delete this block once there is timezone support in the populating script
$setTimeZone = date_default_timezone_set('UTC');
$today = date('Y-m-d');
// Get the current date in UTC
$timeZoneOffset = '+00:00';
$key = wfMemcKey('fundraiserdailytotal', $timeZoneOffset, $today, $fudgeFactor);
$cache = $wgMemc->get($key);
if ($cache != false && $cache != -1) {
return $cache;
}
// Use MediaWiki slave database
$dbr = wfGetDB(DB_SLAVE);
$result = $dbr->select('public_reporting_days', 'round( prd_total ) AS total', array('prd_date' => $today), __METHOD__);
$row = $dbr->fetchRow($result);
if ($row['total'] > 0) {
$total = $row['total'];
} else {
$total = 0;
}
// Make sure the fudge factor is a number
if (is_nan($fudgeFactor)) {
$fudgeFactor = 0;
}
// Add the fudge factor to the total
$total += $fudgeFactor;
$wgMemc->set($key, $total, $egFundraiserStatisticsCacheTimeout);
return $total;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:38,代码来源:DailyTotal_body.php
示例10: validateValue
public function validateValue($value, $field, $model)
{
$value = $this->cast($value, $field, $model);
$def = $model->fields[$field];
if (is_null($value)) {
$required = $model->checkFieldOptionCondition($field, 'required', false);
if (!$required || !$model->exists() && $model->primaryKey === $field) {
return true;
}
$model->setError($field, 'error-required');
return false;
} else {
if (is_nan($value)) {
$model->setError($field, 'error-numeric');
return false;
}
if (isset($def['gt']) && $value <= $def['gt']) {
$model->setError($field, 'error-numeric-gt');
return false;
}
if (isset($def['gte']) && $value < $def['gt']) {
$model->setError($field, 'error-numeric-gte');
return false;
}
if (isset($def['lt']) && $value >= $def['gt']) {
$model->setError($field, 'error-numeric-lt');
return false;
}
if (isset($def['lte']) && $value > $def['gt']) {
$model->setError($field, 'error-numeric-lte');
return false;
}
}
return parent::validateValue($value, $field, $model);
}
开发者ID:millolab,项目名称:quaver-core,代码行数:35,代码来源:Numeric.php
示例11: dumpScalar
protected function dumpScalar($a)
{
switch (true) {
case null === $a:
$this->line .= 'null';
break;
case true === $a:
$this->line .= 'true';
break;
case false === $a:
$this->line .= 'false';
break;
case INF === $a:
$this->line .= '"n`INF"';
break;
case -INF === $a:
$this->line .= '"n`-INF"';
break;
case is_nan($a):
$this->line .= '"n`NAN"';
break;
case $a > 9007199254740992.0 && is_int($a):
$a = '"n`' . $a . '"';
// JavaScript max integer is 2^53
// JavaScript max integer is 2^53
default:
$this->line .= (string) $a;
break;
}
}
开发者ID:nicolas-grekas,项目名称:Patchwork-sandbox,代码行数:30,代码来源:JsonDumper.php
示例12: getClosestStations
/**
* Returns a list of all stations according to the lang variable and what the API returns. Normally it will have these variables:
* array[i] -> name
-> locationX
-> locationY
-> standardname
*/
private function getClosestStations($y, $x, $system)
{
include "config.php";
//check if the stationslist hasn't been loaded yet and load the systems
if (!isset($this->{$system})) {
try {
$args = array("system" => $system, "lang" => "NL");
$this->{$system} = APICall::execute("stations", $args);
} catch (Exception $e) {
throw $e;
}
}
$output = array();
$stations = $this->{$system};
//Loop and check if distance is smaller then the vicinity, you only want to get stations nearby
foreach ($stations["station"] as $station) {
$dist = $this->distance($x, $station["locationX"], $y, $station["locationY"]);
if (!is_nan($dist) && $dist < $vicinity) {
$station["distance"] = floor($dist * 1000);
//in meters
$output[sizeof($output)] = $station;
}
}
$output = $this->removeDuplicates($output);
return $output;
}
开发者ID:rubenslabbinck,项目名称:InfoScreen,代码行数:33,代码来源:DataLayer.class.php
示例13: brix_to_gravity
function brix_to_gravity()
{
if (is_nan($this->brix)) {
exit;
}
$this->output['b_to_g'] = $this->brix / (258.6 - $this->brix / 258.2 * 227.1) + 1;
}
开发者ID:vid-d,项目名称:calculators,代码行数:7,代码来源:calculate.php
示例14: parse
/**
* Parses the request.
*
* @return void
*/
public function parse()
{
$filterNode = null;
$limit = $this->xpath->evaluate('number(/card:addressbook-query/card:limit/card:nresults)');
if (is_nan($limit)) {
$limit = null;
}
$filter = $this->xpath->query('/card:addressbook-query/card:filter');
if ($filter->length !== 1) {
throw new Sabre_DAV_Exception_BadRequest('Only one filter element is allowed');
}
$filter = $filter->item(0);
$test = $this->xpath->evaluate('string(@test)', $filter);
if (!$test) {
$test = self::TEST_ANYOF;
}
if ($test !== self::TEST_ANYOF && $test !== self::TEST_ALLOF) {
throw new Sabre_DAV_Exception_BadRequest('The test attribute must either hold "anyof" or "allof"');
}
$propFilters = array();
$propFilterNodes = $this->xpath->query('card:prop-filter', $filter);
for ($ii = 0; $ii < $propFilterNodes->length; $ii++) {
$propFilters[] = $this->parsePropFilterNode($propFilterNodes->item($ii));
}
$this->filters = $propFilters;
$this->limit = $limit;
$this->requestedProperties = array_keys(Sabre_DAV_XMLUtil::parseProperties($this->dom->firstChild));
$this->test = $test;
}
开发者ID:RainyBlueSky,项目名称:PHProjekt,代码行数:34,代码来源:AddressBookQueryParser.php
示例15: validateData
function validateData($data, $type)
{
//text check
if ($type == 'abc') {
if ($data == "") {
die("Invalid type");
}
if ($data == " ") {
die("Invalid type");
}
if ($data == " ") {
die("Invalid type");
}
// everything is ok.
//number check
} else {
if ($type == 123) {
if ($data == '') {
die("Invalid type");
}
if (is_nan($data)) {
die("Invalid type");
}
}
}
}
开发者ID:kubar123,项目名称:diploma,代码行数:26,代码来源:topicFunctions.php
示例16: getPrettyString
/**
*
* @param DateTime $date
* @return string
*/
public function getPrettyString(DateTime $date = null)
{
if (is_null($date)) {
return null;
}
$compareTo = new DateTime('now');
$diff = $compareTo->format('U') - $date->format('U');
$dayDiff = floor($diff / 86400);
if (is_nan($dayDiff) || $dayDiff > 365000) {
return '';
}
$date_string = $this->formatDate($date, $this->app['locale'], 'DAY_MONTH');
if ($dayDiff == 0) {
if ($diff < 60) {
return $this->app->trans('phraseanet::temps:: a l\'instant');
} elseif ($diff < 120) {
return $this->app->trans('phraseanet::temps:: il y a une minute');
} elseif ($diff < 3600) {
return $this->app->trans('phraseanet::temps:: il y a %quantity% minutes', ['%quantity%' => floor($diff / 60)]);
} elseif ($diff < 7200) {
return $this->app->trans('phraseanet::temps:: il y a une heure');
} elseif ($diff < 86400) {
return $this->app->trans('phraseanet::temps:: il y a %quantity% heures', ['%quantity%' => floor($diff / 3600)]);
}
} elseif ($dayDiff == 1) {
return $this->app->trans('phraseanet::temps:: hier');
} elseif ($dayDiff < 365 && $dayDiff > 0) {
return $date_string;
} else {
return $this->formatDate($date, $this->app['locale'], 'DAY_MONTH_YEAR');
}
}
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:37,代码来源:phraseadate.php
示例17: inverse
/**
* The Inverse CDF of the distribution
*
* For example, if the calling class CDF definition is CDF($x, $d1, $d2)
* than the inverse is called as inverse($target, $d1, $d2)
*
* @param number $target The area for which we are trying to find the $x
* @param array ...$params List of all the parameters that are needed for the CDF of the
* calling class. This list must be absent the $x parameter.
*
* @todo check the parameter ranges.
* @return $number
*/
public static function inverse($target, ...$params)
{
$initial = static::mean(...$params);
if (is_nan($initial)) {
$initial = static::median(...$params);
}
array_unshift($params, $initial);
$classname = get_called_class();
$CDF_callback = [$classname, 'CDF'];
$PDF_callback = [$classname, 'PDF'];
$tolerance = 1.0E-10;
$dif = $tolerance + 1;
$guess = $params[0];
while ($dif > $tolerance) {
// load the guess into the arguments
$params[0] = $guess;
$y = call_user_func_array($CDF_callback, $params);
// Since the CDF is the integral of the PDF, the PDF is the derivative of the CDF
$slope = call_user_func_array($PDF_callback, $params);
$del_y = $target - $y;
$guess = $del_y / $slope + $guess;
$dif = abs($del_y);
}
return $guess;
}
开发者ID:markrogoyski,项目名称:math-php,代码行数:38,代码来源:Continuous.php
示例18: ulp
/**
* Return the ulp for the given float argument. The ulp is the
* difference between the argument and the next larger float. Note
* that the sign of the float argument is ignored, that is,
* ulp(x) == ulp(-x). If the argument is a NaN, then NaN is returned.
* If the argument is an infinity, then +Inf is returned. If the
* argument is zero (either positive or negative), then
* {@link Float#MIN_VALUE} is returned.
*
* @param float $f
*
* @return float
*/
public static function ulp($f)
{
if (is_nan($f)) {
return $f;
}
if (is_infinite($f)) {
return INF;
}
// This handles both +0.0 and -0.0.
if ($f == 0.0) {
return self::implode(0, 0, 1);
//returns closest value to 0 possible without being 0
}
$bits = self::explode($f);
$bits[0] = 0;
$mantissa = $bits[2];
$exponent = $bits[1];
// Denormal number, so the answer is easy.
if ($bits[1] == 0) {
$bits[2] = 1;
//set fraction to smallest possible value
return self::implode($bits);
}
// Conceptually we want to have '1' as the mantissa. Then we would
// shift the mantissa over to make a normal number. If this underflows
// the exponent, we will make a denormal result.
$bits[1] -= 23;
$bits[2] = 0;
if ($bits[1] == 0) {
$bits[2] = 1 << -($bits[1] - 1);
$bits[1] = 0;
}
return self::implode($bits);
}
开发者ID:OakbankTechnologyInc,项目名称:Math,代码行数:47,代码来源:MathFloat.php
示例19: stringify
/**
* @param mixed $value
* @param int $depth
*
* @return string
*/
public static function stringify($value, $depth = 1)
{
if ($depth >= self::$maxDepthStringify) {
return self::$maxReplacementStringify;
}
if (is_array($value)) {
return static::stringifyArray($value, $depth);
}
if (is_object($value)) {
return static::stringifyObject($value, $depth);
}
if (is_resource($value)) {
return sprintf('`[resource] (%s)`', get_resource_type($value));
}
if (is_float($value)) {
if (is_infinite($value)) {
return ($value > 0 ? '' : '-') . 'INF';
}
if (is_nan($value)) {
return 'NaN';
}
}
$options = 0;
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
$options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
}
return @json_encode($value, $options) ?: $value;
}
开发者ID:nowsolutions,项目名称:Validation,代码行数:34,代码来源:ValidationException.php
示例20: logQuery
public function logQuery(array $query)
{
dump($query);
exit;
if ($this->logger === NULL) {
return;
}
if (isset($query['batchInsert']) && NULL !== $this->batchInsertTreshold && $this->batchInsertTreshold <= $query['num']) {
$query['data'] = '**' . $query['num'] . ' item(s)**';
}
array_walk_recursive($query, function (&$value, $key) {
if ($value instanceof \MongoBinData) {
$value = base64_encode($value->bin);
return;
}
if (is_float($value) && is_infinite($value)) {
$value = ($value < 0 ? '-' : '') . 'Infinity';
return;
}
if (is_float($value) && is_nan($value)) {
$value = 'NaN';
return;
}
});
$this->logger->debug($this->prefix . json_encode($query));
}
开发者ID:bazo,项目名称:nette-document-manager-extension,代码行数:26,代码来源:Logger.php
注:本文中的is_nan函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论