News for hackers. Stuff that matters.
Re:Everything I wish I knew when learning C by xigoi on Tuesday November 29, 2022 @12:56AM (#33784152)
> IIRC C has an informal guarantee that no primitive syntax will ever cause the CPU to do more than O(1) work at runtime.

How about CPUs that have no, say, division instruction, so it has to be emulated with a loop?

Re:Everything I wish I knew when learning C by naniwaduni on Tuesday November 29, 2022 @04:52PM (#33793871)
Fixed-width divisions are O(1), just comparatively expensive (and potentially optimized to run in variable time). Consider that you can do long division on pairs of numerals of, say, up to 20 digits and be Pretty Confident of an upper bound on how long it's going to take you (you know it's not going to take more than 20 rounds), even though it's going to take you longer to do that than it would for you to add them.