Live data from Hacker News

Pretty.c

github.com

181–190 of 227 posts

Re: Pretty.c

#182
post #181

Earlier quoted context omitted.

It requires a different compiler. This is just a collection of C preprocessor macros

The Zig toolchain can compile both Zig and C.

Yes, but the Zig toolchain is not $YOUR_EXISTING_C_COMPILER_YOU_ALREADY_KNOW_AND_USE

Re: Pretty.c

#183
post #136

Earlier quoted context omitted.

generally they aren't, as scripting usually implies an interpreter, though no one is stopping you from using a wrapping script that quietly compiles on first run and caches a bunch of executables somewhere. not much different than python producing bytecode files as it goes along.

Script usually implies some kind of task that runs once and the exits. As opposed to a system that is expected to run indefinitely. There are good reasons for why scripts are often interpreted and why systems are often compiled, but that's not what defines them. There are definitely scripts that are compiled and systems that are interpreted out in the wild.

'scripting' is an ill-defined term with many interpretations, certainly.

Re: Pretty.c

#184
post #133
post #95

Earlier quoted context omitted.

Indeed, FLT_EPSILON is not a one-size-fits-all solution, but it's good enough for frequent case of comparing big enough numbers, which is not covered by regular ==. So it's a convenience/correctness trade-off I'm ready to make.

If the numbers you are comparing are greater than 2, abs(a - b) < FLT_EPSILON is equivalent to a == b. Because it's not possible for two large numbers to not be equal, but also closer together than FLT_EPSILON.

what

    // FLT_EPSILON == 0.01
    equal(4.999, 5); // true
    4.999 == 5;      // false
am i missing?

Re: Pretty.c

#185
post #129

> The goals for Pretty C are: > Provide so much syntactic sugar as to cause any C developer a diabetes-induced heart attack. :-D

As someone who just got diagnosed with type-1 diabetes (the auto-immune variety, not the “you eat too much sugar” variety), this was far more depressing than funny. I’m probably being overly-sensitive, but man my life has gone to shit in the last couple of years…

Sorry to hear.

Honest advice: I have heard fasting + healthy diet can permanently fix diabetes (though I forgot which type)

Maybe try it? Good luck in any case!

Re: Pretty.c

#189
post #133

Earlier quoted context omitted.

If the numbers you are comparing are greater than 2, abs(a - b) < FLT_EPSILON is equivalent to a == b. Because it's not possible for two large numbers to not be equal, but also closer together than FLT_EPSILON.

what // FLT_EPSILON == 0.01 equal(4.999, 5); // true 4.999 == 5; // false am i missing?

FLT_EPSILON is not 0.01, it's 0.00000011920929.

But it's impossible to have a number that's 0.00000011920929 less than 5.0, or 0.00000011920929 more than 5.0, because the floats with enough magnitude to represent 5 are spaced further apart than that. Only numbers with magnitude In other words, the only 32-bit float that's within ±0.00000011920929 of 5.0 is 5.0 itself.

Post reply on HN