cinera_handmade.network/cmuratori/hero/code/code329.hmml

55 lines
4.0 KiB
Plaintext

[video output=day329 member=cmuratori stream_platform=twitch stream_username=handmade_hero project=code title="Printing Out Floats Poorly" vod_platform=youtube id=Qqp-O4cujVM annotator=Miblo]
[0:28][Recap and set the stage for the day]
[2:29][Run the game and refamiliarise ourselves with the code]
[3:51][handmade_shared.h: Fix an ArrayCount() call in FormatStringList()]
[5:37][handmade_shared.h: Introduce F64ToASCII() and consider precision]
[8:47]["I am not a floating point guru"][quote 524]
[9:06][Blackboard: Float Printing]
[11:37][Blackboard: The problematic concept of the decimal point]
[14:28][Blackboard: Breaking this fractional problem down]
[15:25][Internet: modf[ref
site="C++ Reference"
page="modf"
url="http://www.cplusplus.com/reference/cmath/modf/"]]
[17:21][Blackboard: Summing the fractional parts together]
[21:00][handmade_shared.h: Implement F64ToASCII()]
[28:36][Compile and run, see that our precision looks messed up and investigate why]
[29:45][handmade_shared.h: Make FormatStringList() set Precision if not set, and bake the string reversal code in to U64ToASCII()]
[37:03][Debugger: Step in to U64ToASCII() to take a look at what that does]
[41:03][handmade_shared.h: Endeavour to handle precision correctly]
[42:31][Internet: Consult the printf spec[ref
site="C++ Reference"
page="printf"
url="http://www.cplusplus.com/reference/cstdio/printf/"]]
[42:51]["Chrome? Chrooooooome?"][quote 525]
[46:05][handmade_shared.h: Make FormatStringList() handle the Width in accordance with the printf spec]
[47:18][Run the game and see that the printouts are untouched]
[47:37][handmade_shared.h: Make FormatStringList() correctly compute the Precision]
[49:23][Run the game, see the floating point values looking better and consider what the Width specifier actually means]
[55:00][Q&A][:speech]
[56:26][@zamar037][Does the float printout account for left or right alignment?]
[58:17][@sharlock93][Are we stuck on what something %3d means? I was away]
[59:17][@culver_fly][Sorry if it sounds rude, but why do you even care about the specs? Why don't you just print whatever you want it to be? I mean, it's your code?]
[59:48][handmade_shared.h: Deduplicate the float cases]
[1:01:01][@sharlock93][As far as I know %3.3f means 3 numbers before the decimal and precise to three decimal numbers]
[1:01:35][@mmozeiko][Use the http://cppreference.com it has better docs than cplusplus.com, and cppreference states it's a minimum width]
[1:02:21][@sharlock93][Guess I have been wrong all this time]
[1:02:42][@insofaras][Can you say something quotable for test purposes?]
[1:02:51]["I feel like it's hard to say something quotable on demand"][quote 526]
[1:03:12][@3ygun][Minimum width would make it more consistent across all types of printf]
[1:03:24][@programgamer][So wait, is it a behavior problem or a bad spec problem?]
[1:04:04][@elxenoanizd][Do you think it's worth implementing a custom string class that uses a custom heap for allocation and disposition of memory instead of dealing directly with null-terminated C-strings (talking mostly for tools programming)?]
[1:04:39][@sharlock93][Thanks for the stream, have a good evening, going to work, are you gonna stream at this time from now on?]
[1:05:24][@macielda][Is text printing speed interfering with your profiling accuracy in a significant way?]
[1:05:56][@torgdor][What advantages does this version of printf have over the standard library printf?]
[1:08:12][@longboolean][Right now you are padding with zeros, "the spec", at least in one example, looks like it pads with spaces]
[1:08:33][@elxenoanizd][When is the next Handmade Con?[ref
site="Molly Rocket"
page="HandmadeCon 2016 is GO!"
url="https://mollyrocket.com/news_0033.html"]]
[1:10:08][@music_guru][What else is left other than printf that would need to be removed?]
[1:13:32][@longboolean][Could you explain briefly why this simple approach of printing floats can lead to precision errors?]
[1:14:53][@zeanith64][Will everything be recorded at HandmadeCon? Considering what nearly happened last year, I'm a little worried]
[1:16:28][Wrap it up][:speech]
[/video]