postgis/deps/ryu/ryu.h
Raúl Marín 1343712277 Use the shortest representation when printing doubles
- Use the shortest representation (enough to guarantee roundtrip).
- Uses scientific notation for absolute numbers smaller than 1e-8. The previous behaviour was to output 0 for absolute values smaller than 1e-12 and fixed notation for anything bigger than that.
- Uses scientific notation for absolute numbers greater than 1e+15 (same behaviour).
- The precision parameter now also affects the scientific notation (before it was fixed [5-8]).
- All output functions now respect the requested precision (without any limits).
- The default precision is the same (9 for GeoJSON, 15 for everything else).

Many regress test changed mainly because of the fixes to the precision parameter, which is now respected as the amount of digits after the fixed point.

Closes https://github.com/postgis/postgis/pull/570
Closes #4660
2020-07-28 13:18:38 +02:00

42 lines
1.2 KiB
C

// Copyright 2018 Ulf Adams
//
// The contents of this file may be used under the terms of the Apache License,
// Version 2.0.
//
// (See accompanying file LICENSE-Apache or copy at
// http://www.apache.org/licenses/LICENSE-2.0)
//
// Alternatively, the contents of this file may be used under the terms of
// the Boost Software License, Version 1.0.
// (See accompanying file LICENSE-Boost or copy at
// https://www.boost.org/LICENSE_1_0.txt)
//
// Unless required by applicable law or agreed to in writing, this software
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.
#ifndef RYU_H
#define RYU_H
#ifdef __cplusplus
extern "C" {
#endif
#include <inttypes.h>
/* Print the shortest representation of a double using fixed notation
* Only works for numbers smaller than 1e+17 (absolute value)
* Precision limits the amount of digits of the decimal part
*/
int d2sfixed_buffered_n(double f, uint32_t precision, char* result);
/* Print the shortest representation of a double using scientific notation
* Precision limits the amount of digits of the decimal part
*/
int d2sexp_buffered_n(double f, uint32_t precision, char* result);
#ifdef __cplusplus
}
#endif
#endif // RYU_H