| 1 | #cxx . . $ `<file>/melder/melder_ftoa.h`/ifndef _melder_ftoa_h_ |
| 2 | #define _melder_ftoa_h_cxx . . $ `melder/melder_ftoa.h:2:9`! |
| 3 | /* melder_ftoa.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2019,2021,2024,2026 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 3 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | /* |
| 22 | The following functions return a static string, chosen from a circularly used set of 32 buffers. |
| 23 | You can call at most 32 of them in one Melder_casual call, for instance. |
| 24 | */ |
| 25 | |
| 26 | conststring32cxx . . $ conststring32# Melder_integercxx . . $ Melder_integer(7b348ebc2004441d). (int64cxx . . $ int64# value); |
| 27 | conststring8cxx . . $ conststring8# Melder8_integercxx . . $ Melder8_integer(595caefabb192cea). (int64cxx . . $ int64# value); |
| 28 | |
| 29 | conststring32cxx . . $ conststring32# Melder_bigIntegercxx . . $ Melder_bigInteger(7b348ebc2004441d). (int64cxx . . $ int64# value); |
| 30 | conststring8cxx . . $ conststring8# Melder8_bigIntegercxx . . $ Melder8_bigInteger(595caefabb192cea). (int64cxx . . $ int64# value); |
| 31 | |
| 32 | conststring32cxx . . $ conststring32# Melder_booleancxx . . $ Melder_boolean(dd1c13cd7769a005). (bool value); |
| 33 | conststring8cxx . . $ conststring8# Melder8_booleancxx . . $ Melder8_boolean(626eec357d49c77e). (bool value); |
| 34 | // "yes" or "no" |
| 35 | |
| 36 | conststring32cxx . . $ conststring32# Melder_onoffcxx . . $ Melder_onoff(dd1c13cd7769a005). (bool value); |
| 37 | conststring8cxx . . $ conststring8# Melder8_onoffcxx . . $ Melder8_onoff(626eec357d49c77e). (bool value); |
| 38 | |
| 39 | conststring32cxx . . $ conststring32# Melder_kleeneancxx . . $ Melder_kleenean(d6b360f6e64595dc). (kleeneancxx . . $ kleenean# value); |
| 40 | conststring8cxx . . $ conststring8# Melder8_kleeneancxx . . $ Melder8_kleenean(f9c10809fd01dd9a). (kleeneancxx . . $ kleenean# value); |
| 41 | // "unknown" (< 0), "yes" (> 0), or "no" (0) |
| 42 | |
| 43 | /* |
| 44 | Format a double value as "--undefined--" or something in the "%.15g", "%.16g", or "%.17g" formats. |
| 45 | */ |
| 46 | conststring32cxx . . $ conststring32# Melder_doublecxx . . $ Melder_double(f05d861d9dbec9b2). (double value); |
| 47 | conststring8cxx . . $ conststring8# Melder8_doublecxx . . $ Melder8_double(b2c900d520f7fac6). (double value); |
| 48 | conststring32cxx . . $ conststring32# Melder_double_overtlyRealcxx . . $ Melder_double_overtlyReal(f05d861d9dbec9b2). (double value); |
| 49 | conststring8cxx . . $ conststring8# Melder8_double_overtlyRealcxx . . $ Melder8_double_overtlyReal(b2c900d520f7fac6). (double value); |
| 50 | |
| 51 | /* |
| 52 | Format a double value as "--undefined--" or something in the "%.9g" format. |
| 53 | */ |
| 54 | conststring32cxx . . $ conststring32# Melder_singlecxx . . $ Melder_single(f05d861d9dbec9b2). (double value); |
| 55 | conststring8cxx . . $ conststring8# Melder8_singlecxx . . $ Melder8_single(b2c900d520f7fac6). (double value); |
| 56 | |
| 57 | /* |
| 58 | Format a double value as "--undefined--" or something in the "%.4g" format. |
| 59 | */ |
| 60 | conststring32cxx . . $ conststring32# Melder_halfcxx . . $ Melder_half(f05d861d9dbec9b2). (double value); |
| 61 | conststring8cxx . . $ conststring8# Melder8_halfcxx . . $ Melder8_half(b2c900d520f7fac6). (double value); |
| 62 | |
| 63 | /* |
| 64 | Format a double value as "--undefined--" or something in the "%.*f" format. |
| 65 | */ |
| 66 | conststring32cxx . . $ conststring32# Melder_fixedcxx . . $ Melder_fixed(5b9062840a6ade99). (double value, integercxx . . $ integer# precision); |
| 67 | conststring8cxx . . $ conststring8# Melder8_fixedcxx . . $ Melder8_fixed(5a2420b9f3cfe979). (double value, integercxx . . $ integer# precision); |
| 68 | |
| 69 | /* |
| 70 | Format a double value with a specified precision. If exponent is -2 and precision is 2, you get things like 67E-2 or 0.00024E-2. |
| 71 | */ |
| 72 | conststring32cxx . . $ conststring32# Melder_fixedExponentcxx . . $ Melder_fixedExponent(b2de7e334b37c2bb). (double value, integercxx . . $ integer# exponent, integercxx . . $ integer# precision); |
| 73 | conststring8cxx . . $ conststring8# Melder8_fixedExponentcxx . . $ Melder8_fixedExponent(1fee9a7556312644). (double value, integercxx . . $ integer# exponent, integercxx . . $ integer# precision); |
| 74 | |
| 75 | /* |
| 76 | Format a double value as a percentage. If precision is 3, you get things like "0" or "34.400%" or "0.014%" or "0.001%" or "0.0000007%". |
| 77 | */ |
| 78 | conststring32cxx . . $ conststring32# Melder_percentcxx . . $ Melder_percent(5b9062840a6ade99). (double value, integercxx . . $ integer# precision); |
| 79 | conststring8cxx . . $ conststring8# Melder8_percentcxx . . $ Melder8_percent(5a2420b9f3cfe979). (double value, integercxx . . $ integer# precision); |
| 80 | |
| 81 | /* |
| 82 | Format an integer as a hexadecimal number. If precision is 4, you get things like "0000" or "1A3C" or "107FFFF". |
| 83 | */ |
| 84 | conststring32cxx . . $ conststring32# Melder_hexadecimalcxx . . $ Melder_hexadecimal(3e477d5ccb44e5a4). (integercxx . . $ integer# value, integercxx . . $ integer# precision); |
| 85 | conststring8cxx . . $ conststring8# Melder8_hexadecimalcxx . . $ Melder8_hexadecimal(afd701541d7e629d). (integercxx . . $ integer# value, integercxx . . $ integer# precision); |
| 86 | |
| 87 | /* |
| 88 | Format a dcomplex value as "--undefined--" or something in the "%.15g", "%.16g", or "%.17g" formats, |
| 89 | separated without spaces by "+" or "-" and followed by "i". |
| 90 | */ |
| 91 | conststring32cxx . . $ conststring32# Melder_dcomplexcxx . . $ Melder_dcomplex(4cf419d79128e8b4). (dcomplexcxx . . $ dcomplex# value); |
| 92 | conststring8cxx . . $ conststring8# Melder8_dcomplexcxx . . $ Melder8_dcomplex(6c8e008d8b2e1ffc). (dcomplexcxx . . $ dcomplex# value); |
| 93 | |
| 94 | /* |
| 95 | Format a dcomplex value as "--undefined--" or something in the "%.9g" format, |
| 96 | separated without spaces by "+" or "-" and followed by "i". |
| 97 | */ |
| 98 | conststring32cxx . . $ conststring32# Melder_scomplexcxx . . $ Melder_scomplex(4cf419d79128e8b4). (dcomplexcxx . . $ dcomplex# value); |
| 99 | conststring8cxx . . $ conststring8# Melder8_scomplexcxx . . $ Melder8_scomplex(6c8e008d8b2e1ffc). (dcomplexcxx . . $ dcomplex# value); |
| 100 | |
| 101 | /* |
| 102 | Format the number that is specified by its natural logarithm. |
| 103 | For instance, -10000 is formatted as "1.135483865315339e-4343", which is a floating-point representation of exp(-10000). |
| 104 | */ |
| 105 | conststring32cxx . . $ conststring32# Melder_naturalLogarithmcxx . . $ Melder_naturalLogarithm(f05d861d9dbec9b2). (double lnNumber); |
| 106 | conststring8cxx . . $ conststring8# Melder8_naturalLogarithmcxx . . $ Melder8_naturalLogarithm(b2c900d520f7fac6). (double lnNumber); |
| 107 | |
| 108 | /* |
| 109 | Convert a formatted floating-point string to something suitable for visualization with the Graphics library. |
| 110 | For instance, "1e+4" is turned into "10^^4^", and "-1.23456e-78" is turned into "-1.23456\.c10^^-78^". |
| 111 | */ |
| 112 | conststring32cxx . . $ conststring32# Melder_graphicalHalfcxx . . $ Melder_graphicalHalf(f05d861d9dbec9b2). (double number); |
| 113 | conststring8cxx . . $ conststring8# Melder8_graphicalHalfcxx . . $ Melder8_graphicalHalf(b2c900d520f7fac6). (double number); |
| 114 | conststring32cxx . . $ conststring32# Melder_graphicalSinglecxx . . $ Melder_graphicalSingle(f05d861d9dbec9b2). (double number); |
| 115 | conststring8cxx . . $ conststring8# Melder8_graphicalSinglecxx . . $ Melder8_graphicalSingle(b2c900d520f7fac6). (double number); |
| 116 | conststring32cxx . . $ conststring32# Melder_graphicalDoublecxx . . $ Melder_graphicalDouble(f05d861d9dbec9b2). (double number); |
| 117 | conststring8cxx . . $ conststring8# Melder8_graphicalDoublecxx . . $ Melder8_graphicalDouble(b2c900d520f7fac6). (double number); |
| 118 | conststring32cxx . . $ conststring32# Melder_graphicalPercentcxx . . $ Melder_graphicalPercent(5b9062840a6ade99). (double number, integercxx . . $ integer# precision); |
| 119 | conststring8cxx . . $ conststring8# Melder8_graphicalPercentcxx . . $ Melder8_graphicalPercent(5a2420b9f3cfe979). (double number, integercxx . . $ integer# precision); |
| 120 | conststring32cxx . . $ conststring32# Melder_graphicalNaturalLogarithmcxx . . $ Melder_graphicalNaturalLogarithm(f05d861d9dbec9b2). (double number); |
| 121 | conststring8cxx . . $ conststring8# Melder8_graphicalNaturalLogarithmcxx . . $ Melder8_graphicalNaturalLogarithm(b2c900d520f7fac6). (double number); |
| 122 | |
| 123 | conststring32cxx . . $ conststring32# Melder_pointercxx . . $ Melder_pointer(a9959086b14cc90d). (const void *pointer); |
| 124 | conststring8cxx . . $ conststring8# Melder8_pointercxx . . $ Melder8_pointer(6271d96ae060557f). (const void *pointer); |
| 125 | |
| 126 | conststring32cxx . . $ conststring32# Melder_charactercxx . . $ Melder_character(7ee4a1927ac5447f). (char32cxx . . $ char32# kar); |
| 127 | conststring8cxx . . $ conststring8# Melder8_charactercxx . . $ Melder8_character(7285749b97904bb9). (char32cxx . . $ char32# kar); |
| 128 | |
| 129 | conststring32cxx . . $ conststring32# Melder_colourcxx . . $ Melder_colour(7dfff7c3df3cd0ae). (MelderColourcxx . . $ MelderColour# colour); |
| 130 | conststring8cxx . . $ conststring8# Melder8_colourcxx . . $ Melder8_colour(7473bb70226684fb). (MelderColourcxx . . $ MelderColour# colour); |
| 131 | |
| 132 | /* |
| 133 | Append padding to the left of `string` until the result is at least as long as `width`. |
| 134 | No truncation takes place, so the resulting string may be longer than `width`. |
| 135 | The left edge of `pad` is left-aligned to the resulting string, |
| 136 | so that the result will look good if padding is used for visualizing columns. |
| 137 | */ |
| 138 | conststring32cxx . . $ conststring32# Melder_padLeftcxx . . $ Melder_padLeft(179e3723cc18632b). (conststring32cxx . . $ conststring32# string, integercxx . . $ integer# width, conststring32cxx . . $ conststring32# pad = U" "); |
| 139 | |
| 140 | /* |
| 141 | Append padding to the right of `string` until the result is at least as long as `width`. |
| 142 | No truncation takes place, so the resulting string may be longer than `width`. |
| 143 | The right edge of `pad` is right-aligned to the resulting string, |
| 144 | so that the result will look good if padding is used for visualizing columns. |
| 145 | */ |
| 146 | conststring32cxx . . $ conststring32# Melder_padRightcxx . . $ Melder_padRight(179e3723cc18632b). (conststring32cxx . . $ conststring32# string, integercxx . . $ integer# width, conststring32cxx . . $ conststring32# pad = U" "); |
| 147 | |
| 148 | /* |
| 149 | Cut away the left of `string` until the result is at least as short as `width` (which must be non-negative). |
| 150 | No padding takes place, so the resulting string may be shorter than `width`. |
| 151 | */ |
| 152 | conststring32cxx . . $ conststring32# Melder_truncateLeftcxx . . $ Melder_truncateLeft(2444e786ec90af51). (conststring32cxx . . $ conststring32# string, integercxx . . $ integer# width); |
| 153 | |
| 154 | /* |
| 155 | Cut away the right of `string` until the result is at least as short as `width` (which must be non-negative). |
| 156 | No padding takes place, so the resulting string may be shorter than `width`. |
| 157 | */ |
| 158 | conststring32cxx . . $ conststring32# Melder_truncateRightcxx . . $ Melder_truncateRight(2444e786ec90af51). (conststring32cxx . . $ conststring32# string, integercxx . . $ integer# width); |
| 159 | |
| 160 | /* |
| 161 | Cut away, or prepend padding to, the left of 'string' until the length of the result is 'width' (which must be non-negative). |
| 162 | The resulting string will always have `width` characters. |
| 163 | The left edge of `pad` is left-aligned to the resulting string, |
| 164 | so that the result will look good if padding is used for visualizing columns. |
| 165 | */ |
| 166 | conststring32cxx . . $ conststring32# Melder_padOrTruncateLeftcxx . . $ Melder_padOrTruncateLeft(179e3723cc18632b). (conststring32cxx . . $ conststring32# string, integercxx . . $ integer# width, conststring32cxx . . $ conststring32# pad = U" "); |
| 167 | |
| 168 | /* |
| 169 | Cut away, or append padding to, the right of 'string' until the length of the result is 'width' (which must be non-negative). |
| 170 | The resulting string will always have `width` characters. |
| 171 | The right edge of `pad` is right-aligned to the resulting string, |
| 172 | so that the result will look good if padding is used for visualizing columns. |
| 173 | */ |
| 174 | conststring32cxx . . $ conststring32# Melder_padOrTruncateRightcxx . . $ Melder_padOrTruncateRight(179e3723cc18632b). (conststring32cxx . . $ conststring32# string, integercxx . . $ integer# width, conststring32cxx . . $ conststring32# pad = U" "); |
| 175 | |
| 176 | /* End of file melder_ftoa.h */ |
| 177 | #endif |