예제 #1
0
bigInt *new_bigInt_int(const int value) {
    bigInt *pointer = new_bigInt_array_length(1);
    pointer->digits[0] = value;
    pointer->length = 1;
    pointer->sign = get_sign((type)value);
    return pointer;
}
예제 #2
0
파일: ft_atof.c 프로젝트: atipex/Projets
double			ft_atof(char *num)
{
	t_atof		a;
	int			i;

	i = 0;
	if (!num || !*num)
		return (0);
	init_struct(&a);
	get_sign(&num, &a);
	while (num[i] != '\0')
	{
		if (num[i] >= '0' && num[i] <= '9')
			get_int(num[i], &a);
		else if (num[i] == '.')
		{
			if (a.fraction)
				return (a.sign * (a.integer_part + a.fraction_part
				/ a.divisor));
			else
				a.fraction = 1;
		}
		else
			return (a.sign * (a.integer_part + a.fraction_part / a.divisor));
		i++;
	}
	return (a.sign * (a.integer_part + a.fraction_part / a.divisor));
}
예제 #3
0
void test_one(std::locale const &l,std::string ia,std::string ib,int diff)
{
    std::basic_string<CharType> a=to_correct_string<CharType>(ia,l);
    std::basic_string<CharType> b=to_correct_string<CharType>(ib,l);
    if(diff < 0) {
        TEST(l(a,b));
        TEST(!l(b,a));
    }
    else if(diff == 0) {
        TEST(!l(a,b));
        TEST(!l(b,a));
    }
    else {
        TEST(!l(a,b));
        TEST(l(b,a));
    }

    std::collate<CharType> const &col = std::use_facet<std::collate<CharType> >(l);

    TEST(diff == col.compare(a.c_str(),a.c_str()+a.size(),b.c_str(),b.c_str()+b.size()));
    TEST(diff == get_sign(col.transform(a.c_str(),a.c_str()+a.size()).compare(col.transform(b.c_str(),b.c_str()+b.size()))));
    if(diff == 0) {
        TEST(col.hash(a.c_str(),a.c_str()+a.size()) == col.hash(b.c_str(),b.c_str()+b.size()));
    }
}
예제 #4
0
bigInt *sub_modulus(const bigInt *first, const bigInt *second) {
    if(!first || !first->sign) {
        bigInt *result = deep_copy(second);
        result->sign *= -1;
        return result;
    }
    if(!second || !second->sign)
        return deep_copy(first);

    int compare_first_second = compare_modulus(first, second);
    if(!compare_first_second)
        return new_bigInt(); // return 0
    if(compare_first_second < 0) {
        const bigInt *temp = first;
        first = second;
        second = temp;
    }

    bigInt *result = light_copy(first);
    result->digits = (type *)calloc(result->length_full, sizeof(type));
    memcpy(result->digits, first->digits, first->length * sizeof(type));
    sub_modulus_fast(result, second);

    result->sign *= get_sign(compare_first_second);
    return result;
}
예제 #5
0
파일: inf_sub.c 프로젝트: k6s/tek1
t_nb		*inf_sub(t_nb *n1, t_nb *n2, t_base *s_base, char *ops)
{
    t_nb		*res;
    int		sign;

    if (!(res = malloc(sizeof(*res))))
        return (NULL);
    if (ops)
        res->sign = get_sign(n1, n2, ops[3]);
    else
        res->sign = 0;
    sign = order_operands(&n1, &n2);
    if (!(res->nb = malloc(sizeof(*res) * (n1->len + 3))))
        return (NULL);
    my_bzero(res->nb, n1->len + 3 + 3);
    do_sub_or_add(n1, n2, res, s_base);
    res->sign = (!res->sign && sign)
                || (!sign && res->sign == 3) ? 1 : res->sign;
    res->sign = res->sign == 1 ? 1 : res->sign;
    res->sign = res->sign == 2 ? 0 : res->sign;
    res->sign = res->sign == 3 && sign ? 0 : res->sign;
    if (ops)
        res->len = clean_res(res, n1->len + 3, s_base->base, ops[3]);
    else
        res->len = clean_res(res, n1->len + 3, s_base->base, 0);
    return (res);
}
예제 #6
0
파일: fshow.c 프로젝트: HaiyangXu/csapp
void show_float(unsigned uf)
{
  float f = u2f(uf);
  unsigned exp = get_exp(uf);
  unsigned frac = get_frac(uf);
  unsigned sign = get_sign(uf);

  printf("\nFloating point value %.10g\n", f);
  printf("Bit Representation 0x%.8x, sign = %x, exponent = 0x%.2x, fraction = 0x%.6x\n",
	 uf, sign, exp, frac);
  if (exp == EXP_MASK) {
    if (frac == 0) {
      printf("%cInfinity\n", sign ? '-' : '+');
    } else
      printf("Not-A-Number\n");
  } else {
    int denorm = (exp == 0);
    int uexp = denorm ? 1-BIAS : exp - BIAS;
    int mantissa = denorm ? frac : frac + (1<<FRAC_SIZE);
    float fman = (float) mantissa / (float) (1<<FRAC_SIZE);
    printf("%s.  %c%.10f X 2^(%d)\n",
	   denorm ? "Denormalized" : "Normalized",
	   sign ? '-' : '+',
	   fman, uexp);
  }
}
int main() {
  int a;
  int b;
  klee_make_symbolic(&a, sizeof(a), "a");
  klee_make_symbolic(&b, sizeof(b), "b");
  return get_sign(a,b);
} 
예제 #8
0
// redirection to subtraction and addition of modules
bigInt *add_with_sign(const bigInt *first, const bigInt *second, int sign_of_operation) {
    int sign_first = get_sign(first->sign);
    int sign_second = get_sign(second->sign);

    if(!sign_second)
        return deep_copy(first);
    if(!sign_first) {
        bigInt *result = deep_copy(second);
        result->sign *= sign_of_operation;
        return result;
    }

    if(sign_first + sign_second)
        return sign_of_operation < 0 ? sub_modulus(first, second) : add_modulus(first, second);
    return sign_of_operation < 0 ? add_modulus(first, second) : sub_modulus(second, first);
}
예제 #9
0
void __read_int(File* file, int* v)
{
    int n = 0;
    int sign;

    if (file->handle >= MaxPascalFiles)
    {
	return;
    }
    if (!files[file->handle].readAhead)
    {
	__get_text(file);
    }
    skip_spaces(file);
    sign = get_sign(file);
    while(isdigit(*file->buffer))
    {
	n *= 10;
	n += (*file->buffer) - '0';
	if (!__get_text(file))
	{
	    break;
	}
    }
    *v = n * sign;
}
예제 #10
0
파일: slscanf.c 프로젝트: ebichu/dd-wrt
static int parse_long (SLFUTURE_CONST char **sp, SLFUTURE_CONST char *smax, long *np,
		       long base, unsigned char map[256])
{
   SLFUTURE_CONST char *s, *s0;
   long n;
   int sign;

   s = s0 = get_sign (*sp, smax, &sign);

   n = 0;
   while (s < smax)
     {
	unsigned char value;

	value = map [(unsigned char) *s];
	if (value == 0xFF)
	  break;

	n = base * n + value;
	s++;
     }

   *sp = s;
   if (s == s0)
     return 0;

   *np = n * sign;

   return 1;
}
예제 #11
0
파일: string.c 프로젝트: bandilab/bandicoot
extern double str_real(const char *s, int *error)
{
    *error = 0;

    int sign;
    s = get_sign(s, &sign, error);

    register long double val;
    for (val = 0; *s && *s != '.' && !*error; ++s)
        if (is_digit(*s))
            val = 10 * val + (*s - '0');
        else
            *error = 1;

    if (*s == '.' && !*error) {
        if (*(++s) != '\0') {
            double fract, div;
            for (fract = 0, div = 10; *s && !*error; ++s, div *= 10)
                if (is_digit(*s))
                    fract = fract + (*s - '0') / div;
                else
                    *error = 1;
            val += fract;
        } else
            *error = 1;
    }

    return (double) sign * val;
}
예제 #12
0
void player_move(SDLKey key)
{
	if (playermove->move.moving) return;
	playermove->move.direction = key;
	playermove->move.moving = true;
	playermove->move.sign = get_sign(key);
	playermove->move.distance = 16;
}
예제 #13
0
static ssize_t attr_test_out(struct device *dev,
                             struct device_attribute *attr,
                             const char *buf, size_t count)
{
    int sign = 0;
    sscanf(buf, "%du", &sign);
    get_sign(sign);
    return count;
}
예제 #14
0
bool
wolf::can_eat(entity* other) {
  if (other == nullptr) return true;
  if (other->get_sign() != get_sign()){
    ++fertility;
    return true;
  }
  return false;
}
예제 #15
0
파일: strlen6.c 프로젝트: anithag/kleestr
int main() {
  char a[100];
  char b[100];
  int i;
  klee_make_symbolic(a, 100, "a-print");
  klee_make_symbolic(b, 100, "b-print");
//  klee_make_symbolic(&i, 4, "i");
  return get_sign(a, b, i);
} 
예제 #16
0
파일: ieee_float.cpp 프로젝트: eigold/cbmc
/// Sets *this to the next representable number closer to plus infinity (greater
/// = true) or minus infinity (greater = false).
void ieee_floatt::next_representable(bool greater)
{
  if(is_NaN())
    return;

  bool old_sign=get_sign();

  if(is_zero())
  {
    unpack(1);
    set_sign(!greater);

    return;
  }

  if(is_infinity())
  {
    if(get_sign()==greater)
    {
      make_fltmax();
      set_sign(old_sign);
    }
    return;
  }

  bool dir;
  if(greater)
    dir=!get_sign();
  else
    dir=get_sign();

  set_sign(false);

  mp_integer old=pack();
  if(dir)
    ++old;
  else
    --old;

  unpack(old);

  // sign change impossible (zero case caught earler)
  set_sign(old_sign);
}
예제 #17
0
파일: string.c 프로젝트: bandilab/bandicoot
extern int str_int(const char *s, int *error)
{
    int sign, uerror = 0;
    s = get_sign(s, &sign, error);

    unsigned long long val = str_ulong(s, &uerror);
    *error = *error || uerror || (val > MAX_UINT) || int_overflow(sign, val);
    
    return sign * val;
}
int main() {
  int a[3];/*
  klee_make_symbolic(&a[0], sizeof(a[0]), "a[0]");
  klee_make_symbolic(&a[1], sizeof(a[1]), "a[1]");
  klee_make_symbolic(&a[2], sizeof(a[2]), "a[2]");*/
  a[0] = klee_int("a0");
  a[1] = klee_int("a1");
  a[2] = klee_int("a2");
  return get_sign(a);
}
예제 #19
0
파일: string.c 프로젝트: bandilab/bandicoot
extern long long str_long(const char *s, int *error)
{
    int sign, uerror = 0;
    s = get_sign(s, &sign, error);

    unsigned long long val = str_ulong(s, &uerror);
    *error = *error || uerror || long_overflow(sign, val);

    return sign * val;
}
예제 #20
0
파일: sign8.c 프로젝트: eiselekd/tracegrind
int main(int argc, char **argv)
{
    // Turns on printing
    TNT_START_PRINT();
    char a = 10;
    // Defines int a as tainted
    TNT_MAKE_MEM_TAINTED(&a,1);
    int s = get_sign(a);
    // Turns off printing
    TNT_STOP_PRINT();
    return s;
}
예제 #21
0
파일: sign8.c 프로젝트: wmkhoo/taintgrind
int main(int argc, char **argv)
{
    // Turns on printing
    //TNT_START_PRINT();
    char a = 10;
    // Defines int a as tainted
    TNT_TAINT(&a,sizeof(a));
    int s = get_sign(a);
    // Turns off printing
    //TNT_STOP_PRINT();
    return s;
}
int main() {
  int a;
  klee_make_symbolic(&a, sizeof(a), "a");


char *tmp = getenv("KTEST_FILE");
FILE *file = fopen(".successful_test", "a");
fputs(tmp, file);
fputc('\n', file);
fclose(file);

  return get_sign(a);
} 
예제 #23
0
int32_t get_acceleration (int32_t distance_to_target, int32_t v, int32_t goal_v)
{
	int32_t sign = get_sign(distance_to_target);
	int32_t gooda;
        // Compute our maximum acceleration
	if (sign * v + max_a > max_v) {
		gooda = sign * max_v - v ;
	} else {
		gooda = sign * max_a;
	}
        // Loop while accelerating that way would throw us too far
	while (sign * (v + sd(v + gooda, max_a) - sd(goal_v, max_a) - distance_to_target) > 0) {
		gooda = gooda - sign;
	} 
	return gooda;
}
QNetworkReply* UpyunClientPrivate::downloadFile(const QString &remote_path) {
	QString path_url = "/" + _bucket + "/" + remote_path;
	QString now_time = rfc1123_datetime(time(NULL)).c_str();
	QString auth = get_auth_string(_usr,
			get_sign("GET", path_url, now_time, "0", _pwd));
	// QUrl url = upyun_api_host + path_url;
	QUrl url = QUrl::fromEncoded((g_upyun_api_host + path_url).toLocal8Bit());

	QNetworkRequest request(url);
	request.setRawHeader("Authorization", auth.toLatin1());
	request.setRawHeader("Date", now_time.toLatin1());

	QNetworkReply *reply = _qnam.get(request);

	return reply;
}
예제 #25
0
int main() 
{
    int result = plus_one(5);
    printf("%d\n", result);
    
    char sign = get_sign(-5);
    printf("Sign of %d is %c\n", -5, sign);
    
    printf("Celius: %.2f\n", fahrenheit_to_celsius(44));
    
    printf("%.2f^%d = %.2f\n", 3.0, 3, power(3.0, 3));
    
    double triangleArea = calc_triangle_area(3, 4);
    printf("Area: %.2f", triangleArea);
    
    return (EXIT_SUCCESS);
}
QNetworkReply *UpyunClientPrivate::makeDir(const QString &remote_path) {
	QString path_url = "/" + _bucket + "/" + remote_path;
	QString now_time = rfc1123_datetime(time(NULL)).c_str();
	QString auth = get_auth_string(_usr,
			get_sign("POST", path_url, now_time, "0", _pwd));
	// QUrl url = upyun_api_host + path_url;
	QUrl url = QUrl::fromEncoded((g_upyun_api_host + path_url).toLocal8Bit());

	QNetworkRequest request(url);
	request.setRawHeader("Authorization", auth.toLatin1());
	request.setRawHeader("Content-Length", "0");
	request.setRawHeader("Content-Type", "text/html");
	request.setRawHeader("Date", now_time.toLatin1());
	request.setRawHeader("folder", "create");
	request.setRawHeader("mkdir", "true");

	QNetworkReply *reply = _qnam.post(request, "");

	return reply;
}
예제 #27
0
파일: inf_div.c 프로젝트: k6s/tek1
t_nb		*inf_div(t_nb *n1, t_nb *n2, t_base *s_base, char *ops)
{
  t_nb		*res;

  if (zero_check(n2, s_base->base[0], ops[3], ops[2]))
    {
      my_putstr(SYNTAXE_ERROR_MSG);
      return (NULL);
    }
  if (!(res = malloc(sizeof(*res))))
    return (NULL);
  res->sign = get_sign(n1, n2, ops[3]);
  if (!(res->nb = malloc(sizeof(*res) * (n1->len + 2))))
    return (NULL);
  my_bzero(res->nb, n1->len + 2);
  if (do_div(res, n1, n2, s_base) < 0)
    return (NULL);
  set_ret_sign(res);
  if (!(res->len = clean_res(res, n1->len + 2, s_base->base, ops[3])))
    return (NULL);
  return (res);
}
int main() {
  int a;
  int main;
  klee_make_symbolic(&a, sizeof(a), "a");


char *tmp = getenv("KTEST_FILE");
FILE *file = fopen("C:/Lab/gitOccf/Occf/open-code-coverage-framework/f2k/OccfInsertToTestCode/OccfInsertToTestCode/bin/Debug/.successful_test", "a");
fputs(tmp, file);
fputc('\n', file);
fclose(file);


char *tmp = getenv("KTEST_FILE");
FILE *file = fopen("C:/Lab/OccfProject/OpenCodeCoverageFramework/f2k/OccfInsertToTestCode/OccfInsertToTestCode/bin/Debug/.successful_test", "a");
fputs(tmp, file);
fputc('\n', file);
fclose(file);


char *tmp = getenv("KTEST_FILE");
FILE *file = fopen("C:/Lab/OccfProject/OpenCodeCoverageFramework/f2k/OccfInsertToTestCode/OccfInsertToTestCode/bin/Debug/.successful_test", "a");
fputs(tmp, file);
fputc('\n', file);
fclose(file);


char *tmp = getenv("KTEST_FILE");
FILE *file = fopen("C:/Lab/OccfProject/OpenCodeCoverageFramework/f2k/OccfInsertToTestCode/OccfInsertToTestCode/bin/Debug/.successful_test", "a");
fputs(tmp, file);
fputc('\n', file);
fclose(file);

  return get_sign(a);
//end:
//end:
//end:
//end:
} 
QNetworkReply* UpyunClientPrivate::uploadFile(const QByteArray &filedata,
		const QString &remote_path) {
	QString content_len = QString::number(filedata.length());
	QString path_url = "/" + _bucket + "/" + remote_path;
	QString now_time = rfc1123_datetime(time(NULL)).c_str();

	QString auth = get_auth_string(_usr,
			get_sign("PUT", path_url, now_time, content_len, _pwd));

	// QUrl url = upyun_api_host + path_url;
	QUrl url = QUrl::fromEncoded((g_upyun_api_host + path_url).toLocal8Bit());

	QNetworkRequest request(url);
	request.setRawHeader("Authorization", auth.toLatin1());
	request.setRawHeader("Content-Length", content_len.toLatin1());
	request.setRawHeader("Date", now_time.toLatin1());
	request.setRawHeader("mkdir", "true");

	QNetworkReply *reply = _qnam.put(request, filedata);

	return reply;

}
예제 #30
0
int	getnbr(char *str, char *base)
{
  int	i;
  int	acc;
  int	pow_val;
  int	sign;

  str = get_sign(str, base, &sign);
  if (str == 0)
    return (0);
  i = nbrlen(str) - 1;
  if (my_nboverflow(str, i + 1, sign))
    return (0);
  acc = 0;
  pow_val = 1;
  while (i >= 0)
  {
    acc += pow_val * get_base_id(str[i], base);
    pow_val = pow_val * my_strlen(base);
    i -= 1;
  }
  return (acc * sign);
}