1118 /* ------------------------------------------------------------------------- * |
1118 /* ------------------------------------------------------------------------- * |
1119 * string to number conversion functions * |
1119 * string to number conversion functions * |
1120 * ------------------------------------------------------------------------- */ |
1120 * ------------------------------------------------------------------------- */ |
1121 |
1121 |
1122 |
1122 |
|
1123 /** |
|
1124 * \copydoc cx_strtouz_lc() |
|
1125 */ |
1123 int cx_strtos_lc(cxstring str, short *output, int base, const char *groupsep); |
1126 int cx_strtos_lc(cxstring str, short *output, int base, const char *groupsep); |
|
1127 /** |
|
1128 * \copydoc cx_strtouz_lc() |
|
1129 */ |
1124 int cx_strtoi_lc(cxstring str, int *output, int base, const char *groupsep); |
1130 int cx_strtoi_lc(cxstring str, int *output, int base, const char *groupsep); |
|
1131 /** |
|
1132 * \copydoc cx_strtouz_lc() |
|
1133 */ |
1125 int cx_strtol_lc(cxstring str, long *output, int base, const char *groupsep); |
1134 int cx_strtol_lc(cxstring str, long *output, int base, const char *groupsep); |
|
1135 /** |
|
1136 * \copydoc cx_strtouz_lc() |
|
1137 */ |
1126 int cx_strtoll_lc(cxstring str, long int *output, int base, const char *groupsep); |
1138 int cx_strtoll_lc(cxstring str, long int *output, int base, const char *groupsep); |
|
1139 /** |
|
1140 * \copydoc cx_strtouz_lc() |
|
1141 */ |
1127 int cx_strtoi8_lc(cxstring str, int8_t *output, int base, const char *groupsep); |
1142 int cx_strtoi8_lc(cxstring str, int8_t *output, int base, const char *groupsep); |
|
1143 /** |
|
1144 * \copydoc cx_strtouz_lc() |
|
1145 */ |
1128 int cx_strtoi16_lc(cxstring str, int16_t *output, int base, const char *groupsep); |
1146 int cx_strtoi16_lc(cxstring str, int16_t *output, int base, const char *groupsep); |
|
1147 /** |
|
1148 * \copydoc cx_strtouz_lc() |
|
1149 */ |
1129 int cx_strtoi32_lc(cxstring str, int32_t *output, int base, const char *groupsep); |
1150 int cx_strtoi32_lc(cxstring str, int32_t *output, int base, const char *groupsep); |
|
1151 /** |
|
1152 * \copydoc cx_strtouz_lc() |
|
1153 */ |
1130 int cx_strtoi64_lc(cxstring str, int64_t *output, int base, const char *groupsep); |
1154 int cx_strtoi64_lc(cxstring str, int64_t *output, int base, const char *groupsep); |
|
1155 /** |
|
1156 * \copydoc cx_strtouz_lc() |
|
1157 */ |
1131 int cx_strtoz_lc(cxstring str, ssize_t *output, int base, const char *groupsep); |
1158 int cx_strtoz_lc(cxstring str, ssize_t *output, int base, const char *groupsep); |
|
1159 /** |
|
1160 * \copydoc cx_strtouz_lc() |
|
1161 */ |
1132 int cx_strtous_lc(cxstring str, unsigned short *output, int base, const char *groupsep); |
1162 int cx_strtous_lc(cxstring str, unsigned short *output, int base, const char *groupsep); |
|
1163 /** |
|
1164 * \copydoc cx_strtouz_lc() |
|
1165 */ |
1133 int cx_strtou_lc(cxstring str, unsigned int *output, int base, const char *groupsep); |
1166 int cx_strtou_lc(cxstring str, unsigned int *output, int base, const char *groupsep); |
|
1167 /** |
|
1168 * \copydoc cx_strtouz_lc() |
|
1169 */ |
1134 int cx_strtoul_lc(cxstring str, unsigned long *output, int base, const char *groupsep); |
1170 int cx_strtoul_lc(cxstring str, unsigned long *output, int base, const char *groupsep); |
|
1171 /** |
|
1172 * \copydoc cx_strtouz_lc() |
|
1173 */ |
1135 int cx_strtoull_lc(cxstring str, unsigned long int *output, int base, const char *groupsep); |
1174 int cx_strtoull_lc(cxstring str, unsigned long int *output, int base, const char *groupsep); |
|
1175 /** |
|
1176 * \copydoc cx_strtouz_lc() |
|
1177 */ |
1136 int cx_strtou8_lc(cxstring str, uint8_t *output, int base, const char *groupsep); |
1178 int cx_strtou8_lc(cxstring str, uint8_t *output, int base, const char *groupsep); |
|
1179 /** |
|
1180 * \copydoc cx_strtouz_lc() |
|
1181 */ |
1137 int cx_strtou16_lc(cxstring str, uint16_t *output, int base, const char *groupsep); |
1182 int cx_strtou16_lc(cxstring str, uint16_t *output, int base, const char *groupsep); |
|
1183 /** |
|
1184 * \copydoc cx_strtouz_lc() |
|
1185 */ |
1138 int cx_strtou32_lc(cxstring str, uint32_t *output, int base, const char *groupsep); |
1186 int cx_strtou32_lc(cxstring str, uint32_t *output, int base, const char *groupsep); |
|
1187 /** |
|
1188 * \copydoc cx_strtouz_lc() |
|
1189 */ |
1139 int cx_strtou64_lc(cxstring str, uint64_t *output, int base, const char *groupsep); |
1190 int cx_strtou64_lc(cxstring str, uint64_t *output, int base, const char *groupsep); |
|
1191 |
|
1192 /** |
|
1193 * Converts a string to a number. |
|
1194 * |
|
1195 * The function returns non-zero when conversion is not possible. |
|
1196 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
|
1197 * It sets errno to ERANGE when the target datatype is too small. |
|
1198 * |
|
1199 * @param str the string to convert |
|
1200 * @param output a pointer to the integer variable where the result shall be stored |
|
1201 * @param base 2, 8, 10, or 16 |
|
1202 * @param groupsep each character in this string is treated as group separator and ignored during conversion |
|
1203 * @return zero on success, non-zero if conversion was not possible |
|
1204 */ |
1140 int cx_strtouz_lc(cxstring str, size_t *output, int base, const char *groupsep); |
1205 int cx_strtouz_lc(cxstring str, size_t *output, int base, const char *groupsep); |
1141 |
1206 |
|
1207 /** |
|
1208 * \copydoc cx_strtouz_lc() |
|
1209 */ |
1142 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc(cx_strcast(str), output, base, groupsep) |
1210 #define cx_strtos_lc(str, output, base, groupsep) cx_strtos_lc(cx_strcast(str), output, base, groupsep) |
|
1211 /** |
|
1212 * \copydoc cx_strtouz_lc() |
|
1213 */ |
1143 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc(cx_strcast(str), output, base, groupsep) |
1214 #define cx_strtoi_lc(str, output, base, groupsep) cx_strtoi_lc(cx_strcast(str), output, base, groupsep) |
|
1215 /** |
|
1216 * \copydoc cx_strtouz_lc() |
|
1217 */ |
1144 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc(cx_strcast(str), output, base, groupsep) |
1218 #define cx_strtol_lc(str, output, base, groupsep) cx_strtol_lc(cx_strcast(str), output, base, groupsep) |
|
1219 /** |
|
1220 * \copydoc cx_strtouz_lc() |
|
1221 */ |
1145 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc(cx_strcast(str), output, base, groupsep) |
1222 #define cx_strtoll_lc(str, output, base, groupsep) cx_strtoll_lc(cx_strcast(str), output, base, groupsep) |
|
1223 /** |
|
1224 * \copydoc cx_strtouz_lc() |
|
1225 */ |
1146 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc(cx_strcast(str), output, base, groupsep) |
1226 #define cx_strtoi8_lc(str, output, base, groupsep) cx_strtoi8_lc(cx_strcast(str), output, base, groupsep) |
|
1227 /** |
|
1228 * \copydoc cx_strtouz_lc() |
|
1229 */ |
1147 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc(cx_strcast(str), output, base, groupsep) |
1230 #define cx_strtoi16_lc(str, output, base, groupsep) cx_strtoi16_lc(cx_strcast(str), output, base, groupsep) |
|
1231 /** |
|
1232 * \copydoc cx_strtouz_lc() |
|
1233 */ |
1148 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc(cx_strcast(str), output, base, groupsep) |
1234 #define cx_strtoi32_lc(str, output, base, groupsep) cx_strtoi32_lc(cx_strcast(str), output, base, groupsep) |
|
1235 /** |
|
1236 * \copydoc cx_strtouz_lc() |
|
1237 */ |
1149 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc(cx_strcast(str), output, base, groupsep) |
1238 #define cx_strtoi64_lc(str, output, base, groupsep) cx_strtoi64_lc(cx_strcast(str), output, base, groupsep) |
|
1239 /** |
|
1240 * \copydoc cx_strtouz_lc() |
|
1241 */ |
1150 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc(cx_strcast(str), output, base, groupsep) |
1242 #define cx_strtoz_lc(str, output, base, groupsep) cx_strtoz_lc(cx_strcast(str), output, base, groupsep) |
|
1243 /** |
|
1244 * \copydoc cx_strtouz_lc() |
|
1245 */ |
1151 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc(cx_strcast(str), output, base, groupsep) |
1246 #define cx_strtous_lc(str, output, base, groupsep) cx_strtous_lc(cx_strcast(str), output, base, groupsep) |
|
1247 /** |
|
1248 * \copydoc cx_strtouz_lc() |
|
1249 */ |
1152 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc(cx_strcast(str), output, base, groupsep) |
1250 #define cx_strtou_lc(str, output, base, groupsep) cx_strtou_lc(cx_strcast(str), output, base, groupsep) |
|
1251 /** |
|
1252 * \copydoc cx_strtouz_lc() |
|
1253 */ |
1153 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc(cx_strcast(str), output, base, groupsep) |
1254 #define cx_strtoul_lc(str, output, base, groupsep) cx_strtoul_lc(cx_strcast(str), output, base, groupsep) |
|
1255 /** |
|
1256 * \copydoc cx_strtouz_lc() |
|
1257 */ |
1154 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc(cx_strcast(str), output, base, groupsep) |
1258 #define cx_strtoull_lc(str, output, base, groupsep) cx_strtoull_lc(cx_strcast(str), output, base, groupsep) |
|
1259 /** |
|
1260 * \copydoc cx_strtouz_lc() |
|
1261 */ |
1155 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc(cx_strcast(str), output, base, groupsep) |
1262 #define cx_strtou8_lc(str, output, base, groupsep) cx_strtou8_lc(cx_strcast(str), output, base, groupsep) |
|
1263 /** |
|
1264 * \copydoc cx_strtouz_lc() |
|
1265 */ |
1156 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc(cx_strcast(str), output, base, groupsep) |
1266 #define cx_strtou16_lc(str, output, base, groupsep) cx_strtou16_lc(cx_strcast(str), output, base, groupsep) |
|
1267 /** |
|
1268 * \copydoc cx_strtouz_lc() |
|
1269 */ |
1157 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc(cx_strcast(str), output, base, groupsep) |
1270 #define cx_strtou32_lc(str, output, base, groupsep) cx_strtou32_lc(cx_strcast(str), output, base, groupsep) |
|
1271 /** |
|
1272 * \copydoc cx_strtouz_lc() |
|
1273 */ |
1158 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc(cx_strcast(str), output, base, groupsep) |
1274 #define cx_strtou64_lc(str, output, base, groupsep) cx_strtou64_lc(cx_strcast(str), output, base, groupsep) |
|
1275 /** |
|
1276 * Converts a string to a number. |
|
1277 * |
|
1278 * The function returns non-zero when conversion is not possible. |
|
1279 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
|
1280 * It sets errno to ERANGE when the target datatype is too small. |
|
1281 * |
|
1282 * @param str the string to convert |
|
1283 * @param output a pointer to the integer variable where the result shall be stored |
|
1284 * @param base 2, 8, 10, or 16 |
|
1285 * @param groupsep each character in this string is treated as group separator and ignored during conversion |
|
1286 * @return zero on success, non-zero if conversion was not possible |
|
1287 */ |
1159 #define cx_strtouz_lc(str, output, base, groupsep) cx_strtouz_lc(cx_strcast(str), output, base, groupsep) |
1288 #define cx_strtouz_lc(str, output, base, groupsep) cx_strtouz_lc(cx_strcast(str), output, base, groupsep) |
1160 |
1289 |
|
1290 |
|
1291 /** |
|
1292 * \copydoc cx_strtouz() |
|
1293 */ |
1161 #define cx_strtos(str, output, base) cx_strtos_lc(str, output, base, ",") |
1294 #define cx_strtos(str, output, base) cx_strtos_lc(str, output, base, ",") |
|
1295 /** |
|
1296 * \copydoc cx_strtouz() |
|
1297 */ |
1162 #define cx_strtoi(str, output, base) cx_strtoi_lc(str, output, base, ",") |
1298 #define cx_strtoi(str, output, base) cx_strtoi_lc(str, output, base, ",") |
|
1299 /** |
|
1300 * \copydoc cx_strtouz() |
|
1301 */ |
1163 #define cx_strtol(str, output, base) cx_strtol_lc(str, output, base, ",") |
1302 #define cx_strtol(str, output, base) cx_strtol_lc(str, output, base, ",") |
|
1303 /** |
|
1304 * \copydoc cx_strtouz() |
|
1305 */ |
1164 #define cx_strtoll(str, output, base) cx_strtoll_lc(str, output, base, ",") |
1306 #define cx_strtoll(str, output, base) cx_strtoll_lc(str, output, base, ",") |
|
1307 /** |
|
1308 * \copydoc cx_strtouz() |
|
1309 */ |
1165 #define cx_strtoi8(str, output, base) cx_strtoi8_lc(str, output, base, ",") |
1310 #define cx_strtoi8(str, output, base) cx_strtoi8_lc(str, output, base, ",") |
|
1311 /** |
|
1312 * \copydoc cx_strtouz() |
|
1313 */ |
1166 #define cx_strtoi16(str, output, base) cx_strtoi16_lc(str, output, base, ",") |
1314 #define cx_strtoi16(str, output, base) cx_strtoi16_lc(str, output, base, ",") |
|
1315 /** |
|
1316 * \copydoc cx_strtouz() |
|
1317 */ |
1167 #define cx_strtoi32(str, output, base) cx_strtoi32_lc(str, output, base, ",") |
1318 #define cx_strtoi32(str, output, base) cx_strtoi32_lc(str, output, base, ",") |
|
1319 /** |
|
1320 * \copydoc cx_strtouz() |
|
1321 */ |
1168 #define cx_strtoi64(str, output, base) cx_strtoi64_lc(str, output, base, ",") |
1322 #define cx_strtoi64(str, output, base) cx_strtoi64_lc(str, output, base, ",") |
|
1323 /** |
|
1324 * \copydoc cx_strtouz() |
|
1325 */ |
1169 #define cx_strtoz(str, output, base) cx_strtoz_lc(str, output, base, ",") |
1326 #define cx_strtoz(str, output, base) cx_strtoz_lc(str, output, base, ",") |
|
1327 /** |
|
1328 * \copydoc cx_strtouz() |
|
1329 */ |
1170 #define cx_strtous(str, output, base) cx_strtous_lc(str, output, base, ",") |
1330 #define cx_strtous(str, output, base) cx_strtous_lc(str, output, base, ",") |
|
1331 /** |
|
1332 * \copydoc cx_strtouz() |
|
1333 */ |
1171 #define cx_strtou(str, output, base) cx_strtou_lc(str, output, base, ",") |
1334 #define cx_strtou(str, output, base) cx_strtou_lc(str, output, base, ",") |
|
1335 /** |
|
1336 * \copydoc cx_strtouz() |
|
1337 */ |
1172 #define cx_strtoul(str, output, base) cx_strtoul_lc(str, output, base, ",") |
1338 #define cx_strtoul(str, output, base) cx_strtoul_lc(str, output, base, ",") |
|
1339 /** |
|
1340 * \copydoc cx_strtouz() |
|
1341 */ |
1173 #define cx_strtoull(str, output, base) cx_strtoull_lc(str, output, base, ",") |
1342 #define cx_strtoull(str, output, base) cx_strtoull_lc(str, output, base, ",") |
|
1343 /** |
|
1344 * \copydoc cx_strtouz() |
|
1345 */ |
1174 #define cx_strtou8(str, output, base) cx_strtou8_lc(str, output, base, ",") |
1346 #define cx_strtou8(str, output, base) cx_strtou8_lc(str, output, base, ",") |
|
1347 /** |
|
1348 * \copydoc cx_strtouz() |
|
1349 */ |
1175 #define cx_strtou16(str, output, base) cx_strtou16_lc(str, output, base, ",") |
1350 #define cx_strtou16(str, output, base) cx_strtou16_lc(str, output, base, ",") |
|
1351 /** |
|
1352 * \copydoc cx_strtouz() |
|
1353 */ |
1176 #define cx_strtou32(str, output, base) cx_strtou32_lc(str, output, base, ",") |
1354 #define cx_strtou32(str, output, base) cx_strtou32_lc(str, output, base, ",") |
|
1355 /** |
|
1356 * \copydoc cx_strtouz() |
|
1357 */ |
1177 #define cx_strtou64(str, output, base) cx_strtou64_lc(str, output, base, ",") |
1358 #define cx_strtou64(str, output, base) cx_strtou64_lc(str, output, base, ",") |
|
1359 /** |
|
1360 * Converts a string to a number. |
|
1361 * |
|
1362 * The function returns non-zero when conversion is not possible. |
|
1363 * In that case the function sets errno to EINVAL when the reason is an invalid character or an unsupported base. |
|
1364 * It sets errno to ERANGE when the target datatype is too small. |
|
1365 * |
|
1366 * The comma character is treated as group separator and ignored during parsing. |
|
1367 * If you want to choose the set of group separators, use the \c _lc variant of this function (e.g. cx_strtouz_lc()). |
|
1368 * |
|
1369 * @param str the string to convert |
|
1370 * @param output a pointer to the integer variable where the result shall be stored |
|
1371 * @param base 2, 8, 10, or 16 |
|
1372 * @return zero on success, non-zero if conversion was not possible |
|
1373 */ |
1178 #define cx_strtouz(str, output, base) cx_strtouz_lc(str, output, base, ",") |
1374 #define cx_strtouz(str, output, base) cx_strtouz_lc(str, output, base, ",") |
1179 |
1375 |
|
1376 /** |
|
1377 * Converts a string to a single precision floating point number. |
|
1378 * |
|
1379 * The function returns non-zero when conversion is not possible. |
|
1380 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
|
1381 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
|
1382 * |
|
1383 * The decimal separator is assumed to be a dot character. |
|
1384 * The comma character is treated as group separator and ignored during parsing. |
|
1385 * If you want to choose a different format, use cx_strtof_lc(). |
|
1386 * |
|
1387 * @param str the string to convert |
|
1388 * @param output a pointer to the float variable where the result shall be stored |
|
1389 * @param decsep the decimal separator |
|
1390 * @param groupsep each character in this string is treated as group separator and ignored during conversion |
|
1391 * @return zero on success, non-zero if conversion was not possible |
|
1392 */ |
1180 int cx_strtof_lc(cxstring str, float *output, char decsep, const char *groupsep); |
1393 int cx_strtof_lc(cxstring str, float *output, char decsep, const char *groupsep); |
|
1394 /** |
|
1395 * Converts a string to a double precision floating point number. |
|
1396 * |
|
1397 * The function returns non-zero when conversion is not possible. |
|
1398 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
|
1399 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
|
1400 * |
|
1401 * The decimal separator is assumed to be a dot character. |
|
1402 * The comma character is treated as group separator and ignored during parsing. |
|
1403 * If you want to choose a different format, use cx_strtof_lc(). |
|
1404 * |
|
1405 * @param str the string to convert |
|
1406 * @param output a pointer to the float variable where the result shall be stored |
|
1407 * @param decsep the decimal separator |
|
1408 * @param groupsep each character in this string is treated as group separator and ignored during conversion |
|
1409 * @return zero on success, non-zero if conversion was not possible |
|
1410 */ |
1181 int cx_strtod_lc(cxstring str, double *output, char decsep, const char *groupsep); |
1411 int cx_strtod_lc(cxstring str, double *output, char decsep, const char *groupsep); |
1182 |
1412 |
|
1413 /** |
|
1414 * Converts a string to a single precision floating point number. |
|
1415 * |
|
1416 * The function returns non-zero when conversion is not possible. |
|
1417 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
|
1418 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
|
1419 * |
|
1420 * The decimal separator is assumed to be a dot character. |
|
1421 * The comma character is treated as group separator and ignored during parsing. |
|
1422 * If you want to choose a different format, use cx_strtof_lc(). |
|
1423 * |
|
1424 * @param str the string to convert |
|
1425 * @param output a pointer to the float variable where the result shall be stored |
|
1426 * @param decsep the decimal separator |
|
1427 * @param groupsep each character in this string is treated as group separator and ignored during conversion |
|
1428 * @return zero on success, non-zero if conversion was not possible |
|
1429 */ |
1183 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc(cx_strcast(str), output, decsep, groupsep) |
1430 #define cx_strtof_lc(str, output, decsep, groupsep) cx_strtof_lc(cx_strcast(str), output, decsep, groupsep) |
|
1431 /** |
|
1432 * Converts a string to a double precision floating point number. |
|
1433 * |
|
1434 * The function returns non-zero when conversion is not possible. |
|
1435 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
|
1436 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
|
1437 * |
|
1438 * The decimal separator is assumed to be a dot character. |
|
1439 * The comma character is treated as group separator and ignored during parsing. |
|
1440 * If you want to choose a different format, use cx_strtof_lc(). |
|
1441 * |
|
1442 * @param str the string to convert |
|
1443 * @param output a pointer to the float variable where the result shall be stored |
|
1444 * @param decsep the decimal separator |
|
1445 * @param groupsep each character in this string is treated as group separator and ignored during conversion |
|
1446 * @return zero on success, non-zero if conversion was not possible |
|
1447 */ |
1184 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc(cx_strcast(str), output, decsep, groupsep) |
1448 #define cx_strtod_lc(str, output, decsep, groupsep) cx_strtod_lc(cx_strcast(str), output, decsep, groupsep) |
1185 |
1449 |
|
1450 /** |
|
1451 * Converts a string to a single precision floating point number. |
|
1452 * |
|
1453 * The function returns non-zero when conversion is not possible. |
|
1454 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
|
1455 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
|
1456 * |
|
1457 * The decimal separator is assumed to be a dot character. |
|
1458 * The comma character is treated as group separator and ignored during parsing. |
|
1459 * If you want to choose a different format, use cx_strtof_lc(). |
|
1460 * |
|
1461 * @param str the string to convert |
|
1462 * @param output a pointer to the float variable where the result shall be stored |
|
1463 * @return zero on success, non-zero if conversion was not possible |
|
1464 */ |
1186 #define cx_strtof(str, output) cx_strtof_lc(str, output, '.', ",") |
1465 #define cx_strtof(str, output) cx_strtof_lc(str, output, '.', ",") |
|
1466 /** |
|
1467 * Converts a string to a double precision floating point number. |
|
1468 * |
|
1469 * The function returns non-zero when conversion is not possible. |
|
1470 * In that case the function sets errno to EINVAL when the reason is an invalid character. |
|
1471 * It sets errno to ERANGE when the necessary representation would exceed the limits defined in libc's float.h. |
|
1472 * |
|
1473 * The decimal separator is assumed to be a dot character. |
|
1474 * The comma character is treated as group separator and ignored during parsing. |
|
1475 * If you want to choose a different format, use cx_strtof_lc(). |
|
1476 * |
|
1477 * @param str the string to convert |
|
1478 * @param output a pointer to the float variable where the result shall be stored |
|
1479 * @return zero on success, non-zero if conversion was not possible |
|
1480 */ |
1187 #define cx_strtod(str, output) cx_strtod_lc(str, output, '.', ",") |
1481 #define cx_strtod(str, output) cx_strtod_lc(str, output, '.', ",") |
1188 |
1482 |
1189 #ifdef __cplusplus |
1483 #ifdef __cplusplus |
1190 } // extern "C" |
1484 } // extern "C" |
1191 #endif |
1485 #endif |