MCPcopy Create free account
hub / github.com/numpy/numpy / fix_ascii_format

Function fix_ascii_format

numpy/core/src/common/numpyos.c:253–276  ·  view source on GitHub ↗

* Fix the generated string: make sure the decimal is ., that exponent has a * minimal number of digits, and that it has a decimal + one digit after that * decimal if decimal argument != 0 (Same effect that 'Z' format in * PyOS_ascii_formatd) */

Source from the content-addressed store, hash-verified

251 * PyOS_ascii_formatd)
252 */
253static char*
254fix_ascii_format(char* buf, size_t buflen, int decimal)
255{
256 /*
257 * Get the current locale, and find the decimal point string.
258 * Convert that string back to a dot.
259 */
260 change_decimal_from_locale_to_dot(buf);
261
262 /*
263 * If an exponent exists, ensure that the exponent is at least
264 * MIN_EXPONENT_DIGITS digits, providing the buffer is large enough
265 * for the extra zeros. Also, if there are more than
266 * MIN_EXPONENT_DIGITS, remove as many zeros as possible until we get
267 * back to MIN_EXPONENT_DIGITS
268 */
269 ensure_minimum_exponent_length(buf, buflen);
270
271 if (decimal != 0) {
272 ensure_decimal_point(buf, buflen);
273 }
274
275 return buf;
276}
277
278/*
279 * NumPyOS_ascii_format*:

Callers

nothing calls this directly

Tested by

no test coverage detected