![]() |
|
|||
File indexing completed on 2025-08-28 08:27:14
0001 // Copyright 2010 the V8 project authors. All rights reserved. 0002 // Redistribution and use in source and binary forms, with or without 0003 // modification, are permitted provided that the following conditions are 0004 // met: 0005 // 0006 // * Redistributions of source code must retain the above copyright 0007 // notice, this list of conditions and the following disclaimer. 0008 // * Redistributions in binary form must reproduce the above 0009 // copyright notice, this list of conditions and the following 0010 // disclaimer in the documentation and/or other materials provided 0011 // with the distribution. 0012 // * Neither the name of Google Inc. nor the names of its 0013 // contributors may be used to endorse or promote products derived 0014 // from this software without specific prior written permission. 0015 // 0016 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 0017 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 0018 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 0019 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 0020 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 0021 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 0022 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 0023 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 0024 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0026 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0027 0028 #ifndef DOUBLE_CONVERSION_FAST_DTOA_H_ 0029 #define DOUBLE_CONVERSION_FAST_DTOA_H_ 0030 0031 #include "utils.h" 0032 0033 namespace arrow_vendored { 0034 namespace double_conversion { 0035 0036 enum FastDtoaMode { 0037 // Computes the shortest representation of the given input. The returned 0038 // result will be the most accurate number of this length. Longer 0039 // representations might be more accurate. 0040 FAST_DTOA_SHORTEST, 0041 // Same as FAST_DTOA_SHORTEST but for single-precision floats. 0042 FAST_DTOA_SHORTEST_SINGLE, 0043 // Computes a representation where the precision (number of digits) is 0044 // given as input. The precision is independent of the decimal point. 0045 FAST_DTOA_PRECISION 0046 }; 0047 0048 // FastDtoa will produce at most kFastDtoaMaximalLength digits. This does not 0049 // include the terminating '\0' character. 0050 static const int kFastDtoaMaximalLength = 17; 0051 // Same for single-precision numbers. 0052 static const int kFastDtoaMaximalSingleLength = 9; 0053 0054 // Provides a decimal representation of v. 0055 // The result should be interpreted as buffer * 10^(point - length). 0056 // 0057 // Precondition: 0058 // * v must be a strictly positive finite double. 0059 // 0060 // Returns true if it succeeds, otherwise the result can not be trusted. 0061 // There will be *length digits inside the buffer followed by a null terminator. 0062 // If the function returns true and mode equals 0063 // - FAST_DTOA_SHORTEST, then 0064 // the parameter requested_digits is ignored. 0065 // The result satisfies 0066 // v == (double) (buffer * 10^(point - length)). 0067 // The digits in the buffer are the shortest representation possible. E.g. 0068 // if 0.099999999999 and 0.1 represent the same double then "1" is returned 0069 // with point = 0. 0070 // The last digit will be closest to the actual v. That is, even if several 0071 // digits might correctly yield 'v' when read again, the buffer will contain 0072 // the one closest to v. 0073 // - FAST_DTOA_PRECISION, then 0074 // the buffer contains requested_digits digits. 0075 // the difference v - (buffer * 10^(point-length)) is closest to zero for 0076 // all possible representations of requested_digits digits. 0077 // If there are two values that are equally close, then FastDtoa returns 0078 // false. 0079 // For both modes the buffer must be large enough to hold the result. 0080 bool FastDtoa(double d, 0081 FastDtoaMode mode, 0082 int requested_digits, 0083 Vector<char> buffer, 0084 int* length, 0085 int* decimal_point); 0086 0087 } // namespace double_conversion 0088 } // namespace arrow_vendored 0089 0090 #endif // DOUBLE_CONVERSION_FAST_DTOA_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |