• some guy (unregistered)

    fist*r^2

  • The Mole (unregistered)

    I'm also troubled by the fact that PI is a (local) function not a constant and the calculation operators have been explicitly forced to make a small floating point number before doing the multiplication (wasting precision).

  • OldGuy() (unregistered)

    Erm, what is then? https://www.php.net/manual/en/function.deg2rad.php

    But, if one wanted to re-invent the wheel:

    function degToRad (float $value): float { return ($value * M_PI) / 180; }

    But, if one needed really small or absolutely large floats, PHP_FLOAT_MIN and PHP_FLOAT_MAX should be considered.

  • (nodebb) in reply to The Mole

    PHP does have an M_PI constant as well as a pi() function.

    Then again, it also has a deg2rad() function.

  • Debra (unregistered)

    Actually, pi() is defined as a global function in PHP, and its documentation suggests that "the M_PI constant which yields identical results to pi()", so they're equivalent as far as I'm concerned. I presume using a function probably has larger overhead, but I don't know the language well enough to know for sure. As far as the comment goes, it's funny, but I don't know if that's a WTF on its own : it's clearly wrong, and was probably left in there because the code was originally copied from somewhere else where it did something different. I'd much rather have such amusing comments than ones that want to be helpful but end up being very misleading.

  • Prime Mover (unregistered)

    In addition to the existing library of mistakes with -o at the end of their names, I think we can add "copypesto" to indicate a mistake in copypasta.

    This complements "typo" when a msitake has been made typing, "spello" when a mistake is made in speling, and of course "grammo" when you done a grammatical mistake.

    All we knead now is a similar word for a homophone horror.

  • LXE (unregistered)

    The clear and obvious answer is that there was (in the same file, another file or a StackOverflow code snippet) a conversion function that did exactly what the comment said. It was copied and altered to produce another conversion function. Of course, no test (even if there were any) could verify the accurateness of the comment.

  • LXE (unregistered)

    make a small floating point number before doing the multiplication (wasting precision).

    Wouldn't that only matter for fixed-point formats?

    BTW doing computations on constants before mutable values come in saves cycles in compiled languages (the compiler can do the constexpr math).

  • I'm not a robot (unregistered) in reply to LXE

    Most likely true... but then that raises the question of why they couldn't write such a simple function from scratch.

  • Edd (unregistered)

    //convert radians to comment here

  • Robin (unregistered)

    Someone has just copy pasted a different function, changed the name and implementation, but forgot to change the comment. I expect we've all done similar at some point. What makes this special though (apart from reinventing a library function - which is easy to do when it has several million and the docs are so terrible - and PHP ridiculously having a function to return the constant Pi) is why on Earth you would go from "I need a function that converts degrees to radians" to "I'll just copy this Excel-related function and adjust it". I feel like we're only seeing the tip of something WTF iceberg here...

  • Mitch (unregistered) in reply to Prime Mover

    @ Prime Mover, is Hororphone taken?

  • (nodebb) in reply to Mitch

    I believe it has to end in -o to fit in with the rest, like phono or something similar.

  • someone south of the equator (unregistered)

    Who know, maybe that is the way to convert from timestamps to php dates and the comment is correct ;)

  • Me (unregistered)

    Have worked on a project containing certain C-libraries.

    Each of these libraries generally contained dozens if not hundreds of methods all in a single 'c' file thousands of lines long.

    Many of those functions would repeat certain basic logic every single time in a perfect example of "anti-DRY".

    The functions contained many comments, sometimes with a comment against nearly every line in the most useless way possible. E.g a comment above a line "i++" saying "//increment i".

    The comments that DID matter, you know, the ones that should tell you what the often meaninglessly named function actually does, would just be repeated from some initial function all the way down. And hence be wrong for every function except, obviously, the first one.

    Such a joy to maintain,

  • (nodebb)

    I'm estimating a 25% probability that this comment is actually a joke by the programmer.

  • BeenHereSeenThat back in the 90s (unregistered)

    If this were code under source control, it might be the case that this chunk of code got automatically merged during some branch-to-branch merge and it was too small to be noticeable-- whether that be the program noticing or a human eyeball failed to see it at a glance.

  • Álvaro González (github) in reply to Robin

    apart from reinventing a library function - which is easy to do when it has several million and the docs are so terrible

    I wonder how you can not find it when you get deg2rand() in the search results viewport as soon as you type "deg" or "ra". Perhaps searching for "excel to php"?

    Addendum 2020-09-15 12:43: *deg2rad()

  • (nodebb) in reply to Prime Mover

    My favorite is "thinko"

  • Perri Nelson (unregistered) in reply to Prime Mover

    What, are you homophonic?

  • Perri Nelson (unregistered) in reply to Me

    anti-DRY = WET (Write Everything Twice)

  • James (unregistered) in reply to a person

    Whoosh-o

  • my name (unregistered)

    seeing how excel handles dates (and stuff it considers dates), there actually might be an edge case where this could work. (never bet against excel behaving lika a PHB made software)

  • Zygo (unregistered)

    I use neither Excel nor PHP on a daily basis, but what I've heard said online about both of them would lead me to believe the comment is plausible...or at least accurate enough, often enough, that no one will notice.

  • Programmer Robot 10C-32 (unregistered)

    No on said that they were using the standard Excel date/time format, maybe they are measuring month and day as the angular distance around the sun since the start of the year (in degrees). However, the writer needed to convert this measurement to his custom Access date/time format, which is the same measured angle, but measured in radians.

  • (nodebb) in reply to Perri Nelson

    Pfft. Anti-DRY ==> DRY = Do Repeat Yourself.

  • (nodebb) in reply to Programmer Robot 10C-32

    Ah, yes; the 360-day financial calendar. Via Excel's DAYS360 function.

  • Prime Mover (unregistered)

    I rather like "phono", but it's already been taken by a brand / variety / style of audio connectors.

    "Homophono" is a bit of a mouthful, but I suppose it will do.

    I am also going to take control of "thinko", and as for "whoosho", that has to be promoted as a concept in its own right.

  • (nodebb) in reply to Álvaro González

    deg2rand()

  • Stephen (unregistered) in reply to Prime Mover

    Don't forget scanno, for errors that come from scan & OCR. Tends to cause things like m => rn, rl => it, etc

  • jgh (unregistered)

    What happened to deg1rad() ?

  • erffrfez (unregistered)

    so, what is the article title then?

  • (nodebb) in reply to Perri Nelson

    WET is more of a compliment (complement?) to DRY. The cost of abstraction is sometimes greater than the cost of repeating yourself once; and sometimes, things that look similar enough to be convinced actually aren't. So, write it twice, and then if you see a pattern, start generalizing.

    Addendum 2020-09-28 22:13: s/convinced/combined/

Leave a comment on “//article title here”

Log In or post as a guest

Replying to comment #517627:

« Return to Article