• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IsNaN函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IsNaN函数的典型用法代码示例。如果您正苦于以下问题:C++ IsNaN函数的具体用法?C++ IsNaN怎么用?C++ IsNaN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsNaN函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: MOZ_ASSERT

void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
    MOZ_ASSERT(NS_IsMainThread());
    MSE_API("SourceBuffer(%p)::Remove(aStart=%f, aEnd=%f)", this, aStart, aEnd);
    if (!IsAttached()) {
        aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
        return;
    }
    if (IsNaN(mMediaSource->Duration()) ||
            aStart < 0 || aStart > mMediaSource->Duration() ||
            aEnd <= aStart || IsNaN(aEnd)) {
        aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
        return;
    }
    if (mUpdating || mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
        aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
        return;
    }
    StartUpdating();
    /// TODO: Run coded frame removal algorithm.

    // Run the final step of the coded frame removal algorithm asynchronously
    // to ensure the SourceBuffer's updating flag transition behaves as
    // required by the spec.
    nsCOMPtr<nsIRunnable> event = NS_NewRunnableMethod(this, &SourceBuffer::StopUpdating);
    NS_DispatchToMainThread(event);
}
开发者ID:msliu,项目名称:gecko-dev,代码行数:28,代码来源:SourceBuffer.cpp


示例2: MOZ_ASSERT

void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread());
  MSE_API("Remove(aStart=%f, aEnd=%f)", aStart, aEnd);
  if (!IsAttached()) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  if (mUpdating) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  if (IsNaN(mMediaSource->Duration()) ||
      aStart < 0 || aStart > mMediaSource->Duration() ||
      aEnd <= aStart || IsNaN(aEnd)) {
    aRv.Throw(NS_ERROR_DOM_TYPE_ERR);
    return;
  }
  if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
    mMediaSource->SetReadyState(MediaSourceReadyState::Open);
  }

  RangeRemoval(aStart, aEnd);
}
开发者ID:cstipkovic,项目名称:gecko-dev,代码行数:25,代码来源:SourceBuffer.cpp


示例3: MOZ_ASSERT

void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread());
  MSE_API("Remove(aStart=%f, aEnd=%f)", aStart, aEnd);
  if (!IsAttached()) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  if (mUpdating) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  if (IsNaN(mMediaSource->Duration()) ||
      aStart < 0 || aStart > mMediaSource->Duration() ||
      aEnd <= aStart || IsNaN(aEnd)) {
    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
    return;
  }
  if (mMediaSource->ReadyState() == MediaSourceReadyState::Ended) {
    mMediaSource->SetReadyState(MediaSourceReadyState::Open);
  }

  StartUpdating();
  nsCOMPtr<nsIRunnable> task = new RangeRemovalRunnable(this, aStart, aEnd);
  NS_DispatchToMainThread(task);
}
开发者ID:RobertJGabriel,项目名称:Waterfox,代码行数:27,代码来源:SourceBuffer.cpp


示例4: MOZ_ASSERT

media::TimeIntervals
MediaSourceDecoder::GetSeekable()
{
  MOZ_ASSERT(NS_IsMainThread());
  if (!mMediaSource) {
    NS_WARNING("MediaSource element isn't attached");
    return media::TimeIntervals::Invalid();
  }

  media::TimeIntervals seekable;
  double duration = mMediaSource->Duration();
  if (IsNaN(duration)) {
    // Return empty range.
  } else if (duration > 0 && mozilla::IsInfinite(duration)) {
    media::TimeIntervals buffered = GetBuffered();
    if (buffered.Length()) {
      seekable +=
        media::TimeInterval(media::TimeUnit::FromSeconds(0), buffered.GetEnd());
    }
  } else {
    seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0),
                                    media::TimeUnit::FromSeconds(duration));
  }
  MSE_DEBUG("ranges=%s", DumpTimeRanges(seekable).get());
  return seekable;
}
开发者ID:SJasoria,项目名称:gecko-dev,代码行数:26,代码来源:MediaSourceDecoder.cpp


示例5: calculateNormalizationScale

static float calculateNormalizationScale(ThreadSharedFloatArrayBufferList* response, size_t aLength, float sampleRate)
{
    // Normalize by RMS power
    size_t numberOfChannels = response->GetChannels();

    float power = 0;

    for (size_t i = 0; i < numberOfChannels; ++i) {
        float channelPower = AudioBufferSumOfSquares(static_cast<const float*>(response->GetData(i)), aLength);
        power += channelPower;
    }

    power = sqrt(power / (numberOfChannels * aLength));

    // Protect against accidental overload
    if (!IsFinite(power) || IsNaN(power) || power < MinPower)
        power = MinPower;

    float scale = 1 / power;

    scale *= GainCalibration; // calibrate to make perceived volume same as unprocessed

    // Scale depends on sample-rate.
    if (sampleRate)
        scale *= GainCalibrationSampleRate / sampleRate;

    // True-stereo compensation
    if (response->GetChannels() == 4)
        scale *= 0.5f;

    return scale;
}
开发者ID:bgrins,项目名称:gecko-dev,代码行数:32,代码来源:Reverb.cpp


示例6: IsCacheCorrect

// For NaNs, etc.
static bool IsCacheCorrect(float cached, float actual) {
  if (IsNaN(cached)) {
    // GL is allowed to do anything it wants for NaNs, so if we're shadowing
    // a NaN, then whatever `actual` is might be correct.
    return true;
  }

  return cached == actual;
}
开发者ID:jasonLaster,项目名称:gecko-dev,代码行数:10,代码来源:WebGLContextUtils.cpp


示例7: CheckNaN

 void CheckNaN( const Matrix44& matrix )
 {
     for (int i = 0; i < 16; ++i)
     {
         if (IsNaN( matrix.m[ i ] ))
         {
             //std::cerr << "Matrix contains NaN" << std::endl;
         }
     }
 }
开发者ID:souxiaosou,项目名称:aether3d,代码行数:10,代码来源:Matrix.cpp


示例8: MOZ_ASSERT

void
SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread());
  MSE_API("SourceBuffer(%p)::Remove(aStart=%f, aEnd=%f)", this, aStart, aEnd);
  if (IsNaN(mMediaSource->Duration()) ||
      aStart < 0 || aStart > mMediaSource->Duration() ||
      aEnd <= aStart || IsNaN(aEnd)) {
    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
    return;
  }
  if (!IsAttached() || mUpdating ||
      mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  StartUpdating();
  /// TODO: Run coded frame removal algorithm asynchronously (would call StopUpdating()).
  StopUpdating();
}
开发者ID:bebef1987,项目名称:gecko-dev,代码行数:20,代码来源:SourceBuffer.cpp


示例9: TestDouble

/* Test given float values */
void TestDouble(double a, double b)
{
    DOUB_LONG param1, param2, result, check;

    param1.d = a;
    param2.d = b;
    check.d = param1.d + param2.d;
    result.l = DoubleAdd (param1.l, param2.l);
#if ALWAYS_PRINT
 printf("\n");
 Display(param1, param2, result);
#endif
    if (result.l != check.l && !(IsNaN(result.l) && IsNaN(check.l)) &&
                               !(IsZero(result.l) && IsZero(check.l)))
    {
        printf("\nFailed! Answer should be %e (%08lx).\n", check.d, check.l);
        Display(param1, param2, result);
        printf("\n");
    }
}
开发者ID:mmaloney007,项目名称:Old_CS_Code,代码行数:21,代码来源:main.c


示例10: f4PlaneCoefs

    bool Ray::Intersects(const Plane& plane, F32* distance) const {
        Vector3f planeNormal = plane.GetNormal();
        Vector3f rayEnd = origin + direction * this->distance;

        XMFLOAT4 f4PlaneCoefs(planeNormal.x, planeNormal.y, planeNormal.z, plane.GetDistance());
        XMFLOAT3 f3RayBegin(origin.v);
        XMFLOAT3 f3RayEnd(rayEnd.v);

        XMVECTOR vPlaneCoefs = XMLoadFloat4(&f4PlaneCoefs);
        XMVECTOR vRayBegin = XMLoadFloat3(&f3RayBegin); 
        XMVECTOR vRayEnd = XMLoadFloat3(&f3RayEnd);

        XMVECTOR vIntersection = XMPlaneIntersectLine(vPlaneCoefs, vRayBegin, vRayEnd);
        XMFLOAT3 f3Intersection;
        XMStoreFloat3(&f3Intersection, vIntersection);

		if (IsNaN(f3Intersection.x) || IsNaN(f3Intersection.y) || IsNaN(f3Intersection.z)) {
            return false;
        } else {
            *distance = Vector3f::Distance(origin, Vector3f(f3Intersection.x, f3Intersection.y, f3Intersection.z));
            return true;
        }
    }
开发者ID:panmar,项目名称:pg3,代码行数:23,代码来源:Ray.cpp


示例11: find_minmax

/* ------------------------------------------------------------------------
 * Function: find_minmax
 * ------------------------------------------------------------------------ */
void find_minmax(double *input, int M, 
                 double *minval, int *minind, double *maxval, int *maxind)
{
  int i;

  for (i = 0; i < M; i++) {
    if (!IsNaN(input[i])) {   // init min/max to first non-NAN element
      *minval =  input[i];    *minind = i;   
      *maxval =  input[i];    *maxind = i;
      break;
    }
  }
  if (i == M) {  // special case: if all NaNs
    *minval = GetNaN();  *minind = 0;   *maxval = GetNaN();  *maxind = 0;
  }

  for (; i < M; i++) {   // go through keeping track of min/max
    if      ((input[i] < *minval) && (!IsNaN(input[i]))) 
        {*minval = input[i];  *minind = i;}
    else if ((input[i] > *maxval) && (!IsNaN(input[i]))) 
        {*maxval = input[i];  *maxind = i;}
  }
}
开发者ID:FelixPascal,项目名称:BCILAB,代码行数:26,代码来源:CORE_library.c


示例12: MOZ_ASSERT

void
SourceBuffer::SetAppendWindowEnd(double aAppendWindowEnd, ErrorResult& aRv)
{
    MOZ_ASSERT(NS_IsMainThread());
    MSE_API("SetAppendWindowEnd(aAppendWindowEnd=%f)", aAppendWindowEnd);
    if (!IsAttached() || mUpdating) {
        aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
        return;
    }
    if (IsNaN(aAppendWindowEnd) || aAppendWindowEnd <= mAppendWindowStart) {
        aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
        return;
    }
    mAppendWindowEnd = aAppendWindowEnd;
}
开发者ID:alison-shiue,项目名称:gecko-dev,代码行数:15,代码来源:SourceBuffer.cpp


示例13: ASCIIShade

char ASCIIShade(double x)
{
  if(IsNaN(x)) return 'E';
  if(IsInf(x)==1) return 'I';
  else if(IsInf(x)==-1) return 'i';
  int index = (int)Trunc(x*8) + 7;
  if(index < 0) index=0;
  if(index >= kNumAsciiShades) index=kNumAsciiShades-1;
  if(index == 7) {
    if(x > 0) return kAsciiShades[8];
    else if(x < 0) return kAsciiShades[6];
    else return kAsciiShades[7];
  }
  return kAsciiShades[index];
}
开发者ID:krishauser,项目名称:KrisLibrary,代码行数:15,代码来源:ASCIIShade.cpp


示例14: GetResource

int64_t
SubBufferDecoder::ConvertToByteOffset(double aTime)
{
  // Uses a conversion based on (aTime/duration) * length.  For the
  // purposes of eviction this should be adequate since we have the
  // byte threshold as well to ensure data actually gets evicted and
  // we ensure we don't evict before the current playable point.
  double duration = mParentDecoder->GetMediaSourceDuration();
  if (duration <= 0.0 || IsNaN(duration)) {
    return -1;
  }
  int64_t length = GetResource()->GetLength();
  MOZ_ASSERT(length > 0);
  int64_t offset = (aTime / duration) * length;
  return offset;
}
开发者ID:karzler,项目名称:DivFirefoxTesting,代码行数:16,代码来源:SourceBuffer.cpp


示例15: mon

void
MediaSourceDecoder::SetInitialDuration(int64_t aDuration)
{
  // Only use the decoded duration if one wasn't already
  // set.
  ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
  if (!mMediaSource || !IsNaN(mMediaSourceDuration)) {
    return;
  }
  double duration = aDuration;
  // A duration of -1 is +Infinity.
  if (aDuration >= 0) {
    duration /= USECS_PER_S;
  }
  SetMediaSourceDuration(duration, MSRangeRemovalAction::SKIP);
}
开发者ID:nixiValor,项目名称:Waterfox,代码行数:16,代码来源:MediaSourceDecoder.cpp


示例16: MOZ_ASSERT

void
MediaSource::SetDuration(double aDuration, ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread());
  MSE_API("SetDuration(aDuration=%f, ErrorResult)", aDuration);
  if (aDuration < 0 || IsNaN(aDuration)) {
    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
    return;
  }
  if (mReadyState != MediaSourceReadyState::Open ||
      mSourceBuffers->AnyUpdating()) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  SetDuration(aDuration, MSRangeRemovalAction::RUN);
}
开发者ID:AtulKumar2,项目名称:gecko-dev,代码行数:16,代码来源:MediaSource.cpp


示例17: MOZ_ASSERT

void
MediaSource::SetDuration(double aDuration, ErrorResult& aRv)
{
  MOZ_ASSERT(NS_IsMainThread());
  MSE_API("MediaSource(%p)::SetDuration(aDuration=%f)", this, aDuration);
  if (aDuration < 0 || IsNaN(aDuration)) {
    aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
    return;
  }
  if (mReadyState != MediaSourceReadyState::Open ||
      mSourceBuffers->AnyUpdating()) {
    aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
    return;
  }
  DurationChange(aDuration, aRv);
}
开发者ID:jrmuizel,项目名称:mozilla-central-skia,代码行数:16,代码来源:MediaSource.cpp


示例18: DoubleToBuffer

char* DoubleToBuffer(double value, char* buffer) {
  // DBL_DIG is 15 for IEEE-754 doubles, which are used on almost all
  // platforms these days.  Just in case some system exists where DBL_DIG
  // is significantly larger -- and risks overflowing our buffer -- we have
  // this assert.
  GOOGLE_COMPILE_ASSERT(DBL_DIG < 20, DBL_DIG_is_too_big);

  if (value == numeric_limits<double>::infinity()) {
    strcpy(buffer, "inf");
    return buffer;
  } else if (value == -numeric_limits<double>::infinity()) {
    strcpy(buffer, "-inf");
    return buffer;
  } else if (IsNaN(value)) {
    strcpy(buffer, "nan");
    return buffer;
  }

  int snprintf_result =
    snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG, value);

  // The snprintf should never overflow because the buffer is significantly
  // larger than the precision we asked for.
  GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);

  // We need to make parsed_value volatile in order to force the compiler to
  // write it out to the stack.  Otherwise, it may keep the value in a
  // register, and if it does that, it may keep it as a long double instead
  // of a double.  This long double may have extra bits that make it compare
  // unequal to "value" even though it would be exactly equal if it were
  // truncated to a double.
  volatile double parsed_value = strtod(buffer, NULL);
  if (parsed_value != value) {
    int snprintf_result =
      snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);

    // Should never overflow; see above.
    GOOGLE_DCHECK(snprintf_result > 0 && snprintf_result < kDoubleToBufferSize);
  }

  DelocalizeRadix(buffer);
  return buffer;
}
开发者ID:marmalade,项目名称:protocolbuffers,代码行数:43,代码来源:strutil.cpp


示例19: MOZ_ASSERT

media::TimeIntervals
MediaSourceDecoder::GetSeekable()
{
  MOZ_ASSERT(NS_IsMainThread());
  if (!mMediaSource) {
    NS_WARNING("MediaSource element isn't attached");
    return media::TimeIntervals::Invalid();
  }

  media::TimeIntervals seekable;
  double duration = mMediaSource->Duration();
  if (IsNaN(duration)) {
    // Return empty range.
  } else if (duration > 0 && mozilla::IsInfinite(duration)) {
    media::TimeIntervals buffered = GetBuffered();

    // 1. If live seekable range is not empty:
    if (mMediaSource->HasLiveSeekableRange()) {
      // 1. Let union ranges be the union of live seekable range and the
      // HTMLMediaElement.buffered attribute.
      media::TimeIntervals unionRanges =
        buffered + mMediaSource->LiveSeekableRange();
      // 2. Return a single range with a start time equal to the earliest start
      // time in union ranges and an end time equal to the highest end time in
      // union ranges and abort these steps.
      seekable +=
        media::TimeInterval(unionRanges.GetStart(), unionRanges.GetEnd());
      return seekable;
    }

    if (buffered.Length()) {
      seekable +=
        media::TimeInterval(media::TimeUnit::FromSeconds(0), buffered.GetEnd());
    }
  } else {
    seekable += media::TimeInterval(media::TimeUnit::FromSeconds(0),
                                    media::TimeUnit::FromSeconds(duration));
  }
  MSE_DEBUG("ranges=%s", DumpTimeRanges(seekable).get());
  return seekable;
}
开发者ID:cliqz-oss,项目名称:browser-f,代码行数:41,代码来源:MediaSourceDecoder.cpp


示例20: MOZ_ASSERT

nsresult
MediaSourceDecoder::GetSeekable(dom::TimeRanges* aSeekable)
{
  MOZ_ASSERT(NS_IsMainThread());
  if (!mMediaSource) {
    return NS_ERROR_FAILURE;
  }

  double duration = mMediaSource->Duration();
  if (IsNaN(duration)) {
    // Return empty range.
  } else if (duration > 0 && mozilla::IsInfinite(duration)) {
    nsRefPtr<dom::TimeRanges> bufferedRanges = new dom::TimeRanges();
    mMediaSource->GetBuffered(bufferedRanges);
    aSeekable->Add(bufferedRanges->GetStartTime(), bufferedRanges->GetEndTime());
  } else {
    aSeekable->Add(0, duration);
  }
  MSE_DEBUG("MediaSourceDecoder(%p)::GetSeekable ranges=%s", this, DumpTimeRanges(aSeekable).get());
  return NS_OK;
}
开发者ID:shuangMoz,项目名称:gattdemo1,代码行数:21,代码来源:MediaSourceDecoder.cpp



注:本文中的IsNaN函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsNetworkGame函数代码示例发布时间:2022-05-30
下一篇:
C++ IsMyAddress函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap