r/C_Programming • u/Mysterious-Frame2218 • 4d ago
I need help with ft_printf bonus
Hey guys, I just finished the mandatory part of ft_printf and I'm ready to tackle the bonuses, but I'm not sure where to start. Do you have any tips or strategies on how to implement them? What tools or approaches worked best for you?
3
u/burei00x_ 4d ago
You need to add some context, not everyone knows what this assignment is. I'm a 42 student and I'd advise you to look into the IEEE754 floating point standard. Not sure of all the formats you have to handle for the bonuses but I'm almost certain the floating point formatter is the hardest one to implement. I think some old slack post about this bonus still exists somewhere on the intranet. Best of luck in your endeavors
2
u/ef3d0c3e 17h ago
Floats are not part of the bonuses, thankfully.
I got curios when I did this project and it turns out that formatting floats accurately is extremely tedious.I found this https://ranjitjhala.github.io/static/fp-printing-popl16.pdf which is an accessible read about formatting (and parsing) floats. One caveat is that you always need high precision when formatting. For floats you can use doubles, but for doubles you have to implement your own higher precision floating point numbers.
I found this implementation which is short and easier to understand than the libc implementation you could have on your machine: https://github.com/tobybell/print-float
1
u/burei00x_ 14h ago
Weird, floats were part of the bonus when I did this project about 8 months ago. I didn't do it for the exact reasons you said because I wanted to advance in the curriculum, but still, it's a very good exercise to wrap your head around how fp are represented.
1
12
u/Axman6 4d ago
What are you talking about? The number of people on the internet with no theory of mind is astounding.Β