File: test_strtold.c

package info (click to toggle)
emscripten 2.0.12~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,440 kB
  • sloc: ansic: 510,324; cpp: 384,763; javascript: 84,341; python: 51,362; sh: 50,019; pascal: 4,159; makefile: 3,409; asm: 2,150; lisp: 1,869; ruby: 488; cs: 142
file content (42 lines) | stat: -rw-r--r-- 1,609 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright 2017 The Emscripten Authors.  All rights reserved.
 * Emscripten is available under two separate licenses, the MIT license and the
 * University of Illinois/NCSA Open Source License.  Both these licenses can be
 * found in the LICENSE file.
 */

#include <stdio.h>
#include <stdlib.h>

int main() {
  char* endptr;
  printf("\n");
  printf("%Lg\n", strtold("0", &endptr));
  printf("%Lg\n", strtold("0.", &endptr));
  printf("%Lg\n", strtold("0.0", &endptr));
  printf("%Lg\n", strtold("-0.0", &endptr));
  printf("%Lg\n", strtold("1", &endptr));
  printf("%Lg\n", strtold("1.", &endptr));
  printf("%Lg\n", strtold("1.0", &endptr));
  printf("%Lg\n", strtold("z1.0", &endptr));
  printf("%Lg\n", strtold("0.5", &endptr));
  printf("%Lg\n", strtold(".5", &endptr));
  printf("%Lg\n", strtold(".a5", &endptr));
  printf("%Lg\n", strtold("123", &endptr));
  printf("%Lg\n", strtold("123.456", &endptr));
  printf("%Lg\n", strtold("-123.456", &endptr));
  printf("%Lg\n", strtold("1234567891234567890", &endptr));
  printf("%Lg\n", strtold("1234567891234567890e+50", &endptr));
  printf("%Lg\n", strtold("84e+220", &endptr));
  printf("%Lg\n", strtold("123e-50", &endptr));
  printf("%Lg\n", strtold("123e-250", &endptr));
  printf("%Lg\n", strtold("123e-450", &endptr));
  printf("%Lg\n", strtold("0x6", &endptr));
  printf("%Lg\n", strtold("-0x0p+0", &endptr));
  char str[] = "  12.34e56end";
  printf("%Lg\n", strtold(str, &endptr));
  printf("%zu\n", endptr - str);
  printf("%Lg\n", strtold("84e+420", &endptr));
  printf("%.12Lf\n", strtold("1.2345678900000000e+08", NULL));
  return 0;
}