intutils.c

来自「基于h323协议的软phone」· C语言 代码 · 共 89 行

C
89
字号
/*

NOTICE:
This document contains information that is proprietary to RADVISION LTD..
No part of this publication may be reproduced in any form whatsoever without
written prior approval by RADVISION LTD..

RADVISION LTD. reserves the right to revise this publication and make changes
without obligation to notify any person of such revisions or changes.

*/

/*
  intUtils.c

  Ron S.
  2 May 1996

  int conversion functions.

  */

#include "rvstdio.h"
#include "intutils.h"

#ifdef __cplusplus
extern "C" {
#endif


/*
  Desc: Check if data is a number.
  */
RvBool
isNumber(IN char *data) /* null terminated string. */
{
  char *p = data;

  if (!data) return RV_FALSE;

  while (*p)
  {
    if (!isdigit((int)*p)) return RV_FALSE;
    p++;
  }
  return RV_TRUE;
}



#if ((RV_OS_TYPE != RV_OS_TYPE_WIN32) && (RV_OS_TYPE != RV_OS_TYPE_WINCE))
char *
itoa(int i, char *a, int size)
{
    size=0;
    if (!a) return NULL;

    RvSprintf(a, "%d", i);
    return a;
}
#endif

/* prime numbers__________________________________________________________________________________*/

static RvBool
isPrime(int n)
{
  int i;
  for (i=2; i<n/i/*sqrt(n)*/+1; i++)
    if (!(n%i)) return RV_FALSE;
  return RV_TRUE;
}

int /* first prime number above n */
intFirstPrime(int n)
{
  int i=n;

  if ((i & 1) == 0) i++;
  while (!isPrime(i)) i+=2;
  return i;
}


#ifdef __cplusplus
}
#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?