1 // Copyright 2019 Ulf Adams 2 // 3 // The contents of this file may be used under the terms of the Apache License, 4 // Version 2.0. 5 // 6 // (See accompanying file LICENSE-Apache or copy at 7 // http://www.apache.org/licenses/LICENSE-2.0) 8 // 9 // Alternatively, the contents of this file may be used under the terms of 10 // the Boost Software License, Version 1.0. 11 // (See accompanying file LICENSE-Boost or copy at 12 // https://www.boost.org/LICENSE_1_0.txt) 13 // 14 // Unless required by applicable law or agreed to in writing, this software 15 // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 // KIND, either express or implied. 17 #ifndef RYU_PARSE_H 18 #define RYU_PARSE_H 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 // This is an experimental implementation of parsing strings to 64-bit floats 25 // using a Ryu-like algorithm. At this time, it only support up to 17 non-zero 26 // digits in the input, and also does not support all formats. Use at your own 27 // risk. 28 // 29 // This implementation does not currently support -DRYU_OPTIMIZE_SIZE and always 30 // compiles against the large lookup tables. 31 32 enum Status { 33 SUCCESS, 34 INPUT_TOO_SHORT, 35 INPUT_TOO_LONG, 36 MALFORMED_INPUT 37 }; 38 39 enum Status s2d_n(const char * buffer, const int len, double * result); 40 enum Status s2d(const char * buffer, double * result); 41 42 enum Status s2f_n(const char * buffer, const int len, float * result); 43 enum Status s2f(const char * buffer, float * result); 44 45 #ifdef __cplusplus 46 } 47 #endif 48 49 #endif // RYU_PARSE_H