• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkFloatToDecimal_DEFINED
9 #define SkFloatToDecimal_DEFINED
10 
11 namespace pdfium {
12 namespace skia {
13 
14 constexpr unsigned kMaximumSkFloatToDecimalLength = 49;
15 
16 /** \fn SkFloatToDecimal
17     Convert a float into a decimal string.
18 
19     The resulting string will be in the form `[-]?([0-9]*\.)?[0-9]+` (It does
20     not use scientific notation.) and `sscanf(output, "%f", &x)` will return
21     the original value if the value is finite. This function accepts all
22     possible input values.
23 
24     INFINITY and -INFINITY are rounded to FLT_MAX and -FLT_MAX.
25 
26     NAN values are converted to 0.
27 
28     This function will always add a terminating '\0' to the output.
29 
30     @param value  Any floating-point number
31     @param output The buffer to write the string into.  Must be non-null.
32 
33     @return strlen(output)
34 */
35 unsigned SkFloatToDecimal(float value, char output[kMaximumSkFloatToDecimalLength]);
36 
37 }  // namespace skia
38 }  // namespace pdfium
39 
40 #endif  // SkFloatToDecimal_DEFINED
41