Developer Guide and Reference

Contents

Overview: Intel's Numeric String Conversion Library

Intel's Numeric String Conversion Library,
libistrconv
, provides a collection of routines for converting between ASCII strings and C data types, which are optimized for performance. The
istrconv.h
header file declares prototypes for the library functions.
You can link the
libistrconv
library as a static or shared library on Linux*
and
macOS*
platforms.
On Windows* platforms, you must link
libistrconv
as a static library only.

Using Intel's Numeric String Conversion Library

To use the
libistrconv
library, include the header file,
istrconv.h
, in your program.
Consider the following example
conv.c
file that illustrates how to use the library to convert between string and floating-point data type.
// conv.c #include <stdio.h> #include <istrconv.h> #define LENGTH 20 int main() { const char pi[] = "3.14159265358979323"; char s[LENGTH]; int prec; float fx; double dx; printf("PI: %s\n", pi); printf("single-precision\n"); fx = __IML_string_to_float(pi, NULL); prec = 6; __IML_float_to_string(s, LENGTH, prec, fx); printf("prec: %2d, val: %s\n", prec, s); printf("double-precision\n"); dx = __IML_string_to_double(pi, NULL); prec = 15; __IML_double_to_string(s, LENGTH, prec, dx); printf("prec: %2d, val: %s\n", prec, s); return 0; }
To compile the
conv.c
file on Linux* platforms, use the following command:
icc conv.c –libistrconv
To compile the
conv.c
file on
macOS*
platforms, use the following command:
icc conv.c –libistrconv
To compile the
conv.c
file on Windows* platforms, use the following command:
icl conv.c libistrconv.lib
After you compile this example and run the program, you should get the following results:
PI: 3.14159265358979323 single-precision prec: 6, val: 3.14159 double-precision prec: 15, val: 3.14159265358979

Integer Conversion Functions Optimized with SSE4.2 Instructions

The following integer conversion functions are optimized for better performance with SSE4.2 string processing instructions:
__IML_int_to_string
__IML_uint_to_string
__IML_int64_to_string
__IML_uint64_to_string
__IML_i_to_str
__IML_u_to_str
__IML_ll_to_str
__IML_ull_to_str
__IML_string_to_int