1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2025-04-07 17:32:45 -04:00

Actually enable floating-point arithmetics in printf

This commit is contained in:
Alex Kotov 2022-01-21 04:45:18 +05:00
parent c05c95d8a1
commit 082d3f5ffa
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 11 additions and 0 deletions

View file

@ -3,3 +3,4 @@
* libkernaux 0.1.0 released
* include/kernaux/assert.h: Added unconditional assertion (panic)
* include/kernaux/assert.h: Added guards for unconditional assertion (panic)
* src/printf.c: Fix bug and actually enable floating-point arithmetics

View file

@ -163,6 +163,7 @@ VALUE rb_KernAux_snprintf1(
c == 'e' || c == 'E' ||
c == 'g' || c == 'G')
{
// FIXME: this doesn't work
RB_FLOAT_TYPE_P(arg_rb);
arg.dbl = NUM2DBL(arg_rb);
} else if (c == 'c') {

View file

@ -8,6 +8,10 @@
* Author: Marco Paland (info@paland.com) PALANDesign Hannover, Germany
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <kernaux/libc.h>
#include <kernaux/printf.h>

View file

@ -96,5 +96,10 @@ int main()
test("foo123a%", "%s%u%c%%", "foo", 123, 'a');
test("fooa123%", "%s%c%u%%", "foo", 'a', 123);
#ifdef ENABLE_FLOAT
test("1.200000", "%f", 1.2);
test("123.456789", "%f", 123.456789);
#endif
return 0;
}