• Mr.'; Drop Database -- (unregistered) in reply to Ken B.
    Ken B.:
    PZ:
    22.0f/3 was quite a common way of representing PI in a rough way before frameworks came long and stuck 'official' PI constants in.
    Given that it's only accurate to 2 decimal places, I would think hard-coding "3.14" would be easier.

    Either that, or "355./113". It's only 1 character longer than "22.0f/3" and it's accurate to 6 decimal places.

    4*atan(1) is one character longer again and is as accurate as your floating-point representation.

  • Exxon (unregistered) in reply to C-Derb
    C-Derb:
    Anketam:
    The actual smallest unit of currency in the US is 1/10 of a cent. Just look at gas prices, they love charging 9/10 of a cent per gallon of gas.
    This is TRWTF. When are gas stations going to drop the ridiculous 9/10 of a cent pricing scheme?

    Back in 1950 you could fool people into thinking $.57 9/10 is 3 cents cheaper than $.60 because saving three dimes on your 20 gallon fill up meant something. But today it's going to take at least a two dime difference per gallon to get me to go across the street for some gas.

    When there is a 3 or 4 or 5 on the left side of the decimal point, you need to drop the silly 9/10 of a cent charade.

    It's to make calculation harder when people try to work out 6c a gallon discounts

  • Methuzzella (unregistered) in reply to Tud
    Tud:
    TGV:
    Sayer: you either take the Bible literally, or you don't. There is no FileNotFound option.
    I am not exactly a devout christian, but that's just false. There is no exact border that separates "literally" from "non-literally". Words are just pointers to fuzzy concepts, even without taking into account that they are stored inside brains and their values differ from person to person (apply that to both the word "literally" and the contents of the Bible).
    And I increasingly get the impression that the only people in the world who seem to think the Old Testament is anything even remotely literal are the people who want to argue that Science is right and the bible is wrong and never the twain shall meet.

    Even if the bible (OT) were literal, it has undergone much translation often from languages that could express concepts that we can't (or at least don't). The very beginning of the bible is a case in point: "On the first day God created day and night" Well I'll be damned. Surely the day must already have existed if this was the first day? Sounds like the Big Bang. In the first instant, the universe began. Following that we have now shown "first day" does not literally mean "first day". Extrapolating this to the other six "days" we can actually lead ourselves to believe that Genesis is not entirely inconsistent with the whole idea of evolution. Good heavens, who'd have thunk it?

    Concize version: The bible (Old Testament) is a series of fables not facts. Taken in this context it is clear that Religion and Science don't necessarily have to disagree. I'm sure a lot of scientists will be disappointed (apologies to scientists that aren't, but in my experience it's the science voice attacking the religious voice not the other way around - although I would very much expect it to flow the opposite way)

  • Dromedary (unregistered)

    Nikola Tesla is a genius http://theoatmeal.com/comics/tesla

  • Gerry (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    C-Derb:
    // Convert to negative number
    varInt := StrToInt('-' + IntToStr(varInt));
    
    I'd be willing to bet that this guy (gal?) got better grades in English class than in Math class.
    Probably, but I worry a little about what happens if the number was already negative... What does StrToInt do with "--7"?

    Fail miserably of course:

    Debugger Exception Notification

    Project Project1.exe raised exception class EConvertError with message '''--7'' is not a valid integer value'.

    Break Continue Help

  • Mike (unregistered)

    The testInheritance thing just looks like somebody was learning the language and forgot to remove a piece of experimental code.

  • Squeeself (unregistered) in reply to Paul

    Yup, soon will come a day when code magics itself into existence without a compiler:

    {"FileNotFound", !FILE}

  • (cs) in reply to wonk

    Close. It's:

    #define YASURE 1

    for the Minnesota edition.

  • Troy (unregistered) in reply to mathematician

    Redefining addition, does not make him wrong. It makes you look silly. Especially since you have defined addition in a recursive manner.

  • Jesus (unregistered)

    I say unto thee, thou shalt accept the value of pi as acos(-1).

  • (cs)

    I feel like the first one should be:

    // Hi, I'm a web developer. I have no idea how the web works. Wish me luck!
  • Jim In Texas (unregistered)

    "Rabbi Belaga presents the following explanation: The Hebrew word for line or circumference is written in the Bible as a 3 letter Hebrew word transliterated as kaveh, and whose equivalent English letters are KVH (kof, vav, hei). Yet, that word is read as a 2 letter Hebrew word whose equivalent English letters are KV.

    Hebrew letters have numerical values, and the letters in question have values kof = 100, vav = 6, and hei = 5. So KVH = 100 + 6 + 5 = 111, and KV = 100 + 6 = 106. The ratio of KVH to KV is 111/106, which when multiplied by the value of 3 that was implied by 1 Kings 7:23, gives 3.141509 (rounded), which is again pretty close to pi. "

    http://jerry.praxisiimath.com/pi.html

  • David Martensson (unregistered)

    // Apparently, in at least on situation, a Statically declared public // variable will hold its value across different browser instances making calls to the // same web page. // For now, reset these variables on Page_PreInit.

    In C# at least static properties keep their value until the application domain is reset, which is not done on a per session basis.

    So any static properties will share its value between concurrent and all other sessions handled by the same appdomain, and since an appdomain can live for hours or more that could be a lot of sessions.

    Unfortunately, not every book on C# for the web mentions this little gem making this a fairly common problem for new coders until they stumble on it on their own, I have seen it a few times with new coders here :/

  • Mick (unregistered) in reply to Jay

    Jay wrote: "So you're ridiculing the Bible for, (a) failing to ignore the concept of significant figures, and (b) failing to ignore the fact that pi is a transcendental number. Apparently Moses understood science better than you do."

    Well, the bible also says that rabbits are rumiants and that grasshoppers have 4 legs. Frankly, there are many things in the bible to laugh at. I guess that the creation of the known universe in 7 days is also a clear instance of failure to grasp the concept of exactitude and/or precision... As a source of technical/scientific knowledge, the bible (or the quran, or the torah, or the kavalah or the whatever sacred text you can think of that is a revelation) is as good as News of the World.

  • Ton (unregistered) in reply to Frank

    However, if the "a" key on your keyboard is broken, you can use pi= 22./7 + sin( 22./7 ). It has an error of 1 in 10^10.

  • Braindead (unregistered) in reply to Jim In Texas

    Damn, they sold me a bible without #define statements! I hate when gods don't use #define in their sacred books!

  • Modern believer in scientology (unregistered) in reply to Methuzzella

    Methuzella wrote: "And I increasingly get the impression that the only people in the world who seem to think the Old Testament is anything even remotely literal are the people who want to argue that Science is right and the bible is wrong and never the twain shall meet."

    Well, just exclude christian fundamentalists and all the americans who in surveys declare that they think that everything described in the bible is true, that evolution is false, and you got it... Sacred books of revelation and science cannot meet because revelations are about revealed truths that must be accepted without thinking, while science is about facts and critical thinking. A revelation is written in stone, while science is constantly evolving as theories must improve to reflect correctly the facts of the physical world. But I am glad to know that the bible is not to be taken literally, I guess this means that sins are metaphoric expressions of moral advices, there's no hell and even the concept of soul might be a simple beautification of the idea of human nature. So good to know that the ten commandments are just metaphoric ideas, so I cn actually understand them as I see fit, which after all what all military chaplains have been doing when it comes to the "thou shalt not kill" thingy, since blessing men who are going to kill other men doesn't seem quite a christian idea... But luckily we are XXI century people, and we don't hold irrational beliefs and superstitious ideas.

    captcha: ideo, I create anything with my imagination and make it come true

  • Planar (unregistered) in reply to Infinite Time and Space
    Infinite Time and Space:
    I disagree. Perhaps PI is not really constant throughout all time and positions in the infinite universe? Perhaps it is changing ever so slightly, so slow that in all of human history and in our galaxy, the change would be undetectable. At some point in time and space, it very well could be 3.

    You've got it wrong. The value of PI has nothing to do with time or space, it is a mathematical constant. If you want to change the value of PI, you'll have to change the value of some integers, because of PI is defined by a number of formulas that depend only on natural numbers, for example:

    PI = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...

    see http://en.wikipedia.org/wiki/Pi for more formulas of the same kind.

  • twigg (unregistered)
    /** * Tests if {@link XXXX} class extends {@link Object} class. */ @Test public void testInheritance() { Assert.assertTrue("Class does not extends Object class.", instance instanceof Object); }

    This is generated code.

    There are unit test generators for simple classes (think JavaBeans).

    They make managers happy, as unit test code coverage goes up, while developers don't have to waste time on testing getters and setters.

    Kind of a WTF on it's own...

  • (cs) in reply to justsomedude
    justsomedude:
    N is a measure of force, the question was about weight. If you had been in a physics test you would have got that one wrong.

    What do you think weight is?

    Of course I believe the original question was about mass not weight.

  • (cs) in reply to Dave
    Dave:
    operagost:
    Even if we ignore the definition of the word "miracle", there are plausible circumstances in which a person could walk (or appear to walk) on water.
    I walked across the river Thames last week. Didn't even get wet.

    Useful things, bridges.

    You crossed the Thames, therefore you were in England, therefore it rained on you, so unless you had an umbrella, you got wet.

  • (cs) in reply to DarrenC
    DarrenC:
    operagost:
    Even if we ignore the definition of the word "miracle", there are plausible circumstances in which a person could walk (or appear to walk) on water. But pi is a constant that will never be 3.

    In Pinary, the value of pi is 1.0

    No, in Pinary ("base pi"), the value of pi is pi. It is written as 10.

  • cousteau (unregistered)

    What a bunch of boole sheeit ake.

  • (cs) in reply to Nagesh
    Nagesh:
    pjt33:
    Jay:
    Indeed, when I took chemistry in college, we had a question on a test that said you have a beaker with 40 g of water, you add .01 g of salt, what is the weight of the resultant mixture? The correct answer was 40 g.
    That's how you know it was a chemistry question. If it had been a physics question the correct answer would have been 0.4N (assuming it to be in close proximity to the surface of the Earth).

    Are not good scales available in your country?

    Agree. Doesn't need a special scale to measure that difference. Any half-decent lab scale can do so. it's pretty easy actual so bad example. I would have written 40.01 g and if I failed because of that I would've went to proof experimentally how stupid that question was. They should have chosen a 1 liter of water (= 1 kg which also test if the students are proficient in the metric system :P).

  • (cs) in reply to Jinren
    Jinren:
    KattMan:
    The Christian bible states that PI is 3.

    I like how it's apparently more reasonable to invoke changing universal constants than it is to consider that the book might just have been describing a shitty engineer.

    Or B.S. Johnson.

  • Cbuttius (unregistered) in reply to Steve The Cynic
    Steve The Cynic:
    C-Derb:
    // Convert to negative number
    varInt := StrToInt('-' + IntToStr(varInt));
    
    I'd be willing to bet that this guy (gal?) got better grades in English class than in Math class.
    Probably, but I worry a little about what happens if the number was already negative... What does StrToInt do with "--7"?

    In C++ at least if you try --7 you will get a compiler error "7 is not an l-value" or similar.

  • (cs) in reply to Ninkasi
    Ninkasi:
    Perhaps that's why the Pyramids of Giza are still standing and Solomon's Temple, well, isn't.
    Or it could be that the reason it's no longer standing is because it was destroyed on purpose:
    http://en.wikipedia.org/wiki/Temple_of_Solomon:
    The Temple was plundered by the Babylonian king Nebuchadnezzar when the Babylonians attacked Jerusalem during the brief reign of Jehoiachin c. 598 (2 Kings 24:13), Josiah's grandson. A decade later, Nebuchadnezzar again besieged Jerusalem and after 30 months finally breached the city walls in 587 BCE, subsequently burning the Temple, along with most of the city (2 Kings 25). According to Jewish tradition, the Temple was destroyed on Tisha B'Av, the 9th day of Av (Hebrew calendar).
  • Cbuttius (unregistered)

    the real WTF is posters here who think the book of Kings is a "Christian" book.

  • Cbuttius (unregistered) in reply to Exxon
    Exxon:
    C-Derb:
    Anketam:
    The actual smallest unit of currency in the US is 1/10 of a cent. Just look at gas prices, they love charging 9/10 of a cent per gallon of gas.
    This is TRWTF. When are gas stations going to drop the ridiculous 9/10 of a cent pricing scheme?

    Back in 1950 you could fool people into thinking $.57 9/10 is 3 cents cheaper than $.60 because saving three dimes on your 20 gallon fill up meant something. But today it's going to take at least a two dime difference per gallon to get me to go across the street for some gas.

    When there is a 3 or 4 or 5 on the left side of the decimal point, you need to drop the silly 9/10 of a cent charade.

    It's to make calculation harder when people try to work out 6c a gallon discounts

    The intention is that you don't buy this commodity in single units therefore you never pay the actual unit price.

    Stock is commonly listed in fractions of a penny - on the London Stock Exchange a tick is actually a quarter of a penny. But as you don't buy them in ones, you never actually spend a quarter of a penny.

    Petrol in the UK is at the moment around £1.299 a litre so if you fill your car with 50L you will pay £64.95 rather than £65 you would pay if the price was listed at £1.30

    Yes, it's "only" 5p but it is an amount in legal tender.

  • Vitus (unregistered) in reply to Oak
    Oak:
    Infinite Time and Space:
    operagost:
    Even if we ignore the definition of the word "miracle", there are plausible circumstances in which a person could walk (or appear to walk) on water. But pi is a constant that will never be 3.

    I disagree. Perhaps PI is not really constant throughout all time and positions in the infinite universe? Perhaps it is changing ever so slightly, so slow that in all of human history and in our galaxy, the change would be undetectable. At some point in time and space, it very well could be 3.

    Wrong. Pi is dependent on the curvature of space. In a largely flat space it is what we measure it to be. In a rather curved space you will find it smaller or bigger depending on the type curvature. In the early universe it would have been much smaller so there was a time when it was 3

    You are confusing physical constants - such as the speed of light- which theoretically could change, with mathematical constants - such as pi - which are completely independent from the universe. Pi cannot change.

  • Vitus (unregistered) in reply to Oak
    Oak:
    Infinite Time and Space:
    operagost:
    Even if we ignore the definition of the word "miracle", there are plausible circumstances in which a person could walk (or appear to walk) on water. But pi is a constant that will never be 3.

    I disagree. Perhaps PI is not really constant throughout all time and positions in the infinite universe? Perhaps it is changing ever so slightly, so slow that in all of human history and in our galaxy, the change would be undetectable. At some point in time and space, it very well could be 3.

    You are confusing physical constants - such as the speed of light- which theoretically could change, with mathematical constants - such as pi - which are completely independent from the universe. Pi cannot change.

    Wrong. Pi is dependent on the curvature of space. In a largely flat space it is what we measure it to be. In a rather curved space you will find it smaller or bigger depending on the type of curvature. In the early universe it would have been much smaller so there was a time when it was 3.

  • Vitus (unregistered) in reply to Planar
    Planar:
    Infinite Time and Space:
    I disagree. Perhaps PI is not really constant throughout all time and positions in the infinite universe? Perhaps it is changing ever so slightly, so slow that in all of human history and in our galaxy, the change would be undetectable. At some point in time and space, it very well could be 3.

    You've got it wrong. The value of PI has nothing to do with time or space, it is a mathematical constant. If you want to change the value of PI, you'll have to change the value of some integers, because of PI is defined by a number of formulas that depend only on natural numbers, for example:

    PI = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...

    see http://en.wikipedia.org/wiki/Pi for more formulas of the same kind.

    Nope, Pi is the ratio of circumference and diameter of a circle and that can change. The numeric methods to calculate it you mention are only valid in an Euclidean space. So yes there is conceivably a time and place where it was 3.0.

  • Peter (unregistered) in reply to PiisAWheeL
    PiisAWheeL:
    Tristram:
    Ooh, I know how to fix this code. Works as advertised:

    // Convert to negative number

    varInt := StrToInt('-1');

    That fails on an input below 0.
    No, works perfectly. The comment says "Convert to negative number", not "Convert to opposite sign".

  • (cs) in reply to TGV
    TGV:
    you either take the Bible literally, or you don't.

    Wrong. Try again.

  • ¯\(°_o)/¯ I DUNNO LOL (unregistered)
    function filexists($file) { $retval=0; if(file_exists($file)) $retval=1; return $retval; }
    This proves that you can write PHP in any language.
  • Hmmmm (unregistered) in reply to Vitus
    Vitus:
    Nope, Pi is the ratio of circumference and diameter of a circle and that can change. The numeric methods to calculate it you mention are only valid in an Euclidean space. So yes there is conceivably a time and place where it was 3.0.

    Actually Pi is the ratio of the circumference and diameter of an idealised circle in flat (Euclidean) space. The value of Pi doesn't change in curved space, it is the formula C = Pi * d that changes according to the measure of the curvature of the space.

  • Infinite Time and Space (unregistered) in reply to lanmind
    lanmind:
    TGV:
    you either take the Bible literally, or you don't.

    Wrong. Try again.

    Could be right, could be wrong. Depends if it is an AND or OR condition. If it is an AND condition, then you either take the entire bible literally, or if you take part literally and port not, then you do NOT take the bible literally. If it is on OR condition, then if you take any part of the bible literally, then you take the bible literally.

    XOR means you worship Satan, but not literally.

  • prophet's apprentice (unregistered) in reply to Methuzzella
    Methuzzella:
    The very beginning of the bible is a case in point: "On the first day God created day and night" Well I'll be damned. Surely the day must already have existed if this was the first day?

    That's how people remember it. But acutally, whoever wrote that part of Genesis did pay some attention to detail. There God creates light, then separates light from darkness, thus causing the first day.

  • Sayer (unregistered) in reply to TGV
    TGV:
    Sayer:
    Or we can assume that the dude writing the passage was a scribe and not a fucking engineer - therefore making any inaccuracies in reporting the measurement hardly surprising or noteworthy.
    Someone's getting upset and using ugly words that have been forbidden by his god, or rather, the people that claim to be the representatives of his deity of preference.

    Sayer: you either take the Bible literally, or you don't. There is no FileNotFound option.

    And someone's making all kinds of assumptions just because my stance against stupid and dishonest arguing has me appearing to support a viewpoint I often find idiotic.

    Sayer: you either take the Bible literally, or you don't. There is no FileNotFound option.

    This is bullshit. (gosh, I hope I didn't hurt your ears) There are all kinds of reasons not to take the Bible literally, but the rounding errors or poor mathematical understanding of the guy writing it down is a pretty flimsy one. The book is full of contradictions and all kinds of other nonsense like rules on which fabrics to never wear together. Try fucking harder.

  • (cs) in reply to Herohtar
    Herohtar:
    I was expecting one of the first comments to be a "GRAVEYARD OF BAD COMMENTS" marker. I am greatly disappointed.
    Are you new here? Every WTF posted has a graveyard of bad comments.
  • Persto (unregistered) in reply to Ninkasi
    Ninkasi:
    Oh, yay, this argument again. Okay, let's run with this.

    So you're saying that 1 Kings 7 is an engineering document, and as such only needs to be accurate to within the engineering tolerances of Solomon's temple. Hey, I'll buy that. The whole chapter is discussing the dimensions of the building in detail. I guess that means the temple, then, was built to a tolerance of 1.4 cubits, or about one meter.

    Meanwhile, contemporary construction by the Egyptians was built to tolerances lower than a couple millimeters (the thickness of a sheet of papyrus, anyway). Perhaps that's why the Pyramids of Giza are still standing and Solomon's Temple, well, isn't.

    As an engineer myself, maybe I should be praying to Ra and Anubis, instead.

    That should work out fine as a Cristian, since Cristianity and of Eqyptology. and Jesus the reborn Horus or Ra.

  • PZ (unregistered) in reply to sdfdh

    I just remember being taught (and this was probably a maths class rather than a computer class) that 22/7 was a 'good enough' estimation of PI for rough calculations.

    I would guess this is where the funny code came from - somebody from a maths background (or who remembered it from a maths class), and not even realising there's another way in most computer languages these days.

  • Herr Otto Flick (unregistered) in reply to Nagesh
    Nagesh:
    Also
    Nagesh:
    null:
    public static int getNegativeOfNumber ( int num ) { return num > 0 ? num * -1 : num; }
    U ain't remembering to put in semi-colons.

    You're all wrong:

    int negate(int num) { return 1 + ~ num; }

  • (cs) in reply to Vitus
    Vitus:
    Planar:
    Infinite Time and Space:
    I disagree. Perhaps PI is not really constant throughout all time and positions in the infinite universe? Perhaps it is changing ever so slightly, so slow that in all of human history and in our galaxy, the change would be undetectable. At some point in time and space, it very well could be 3.

    You've got it wrong. The value of PI has nothing to do with time or space, it is a mathematical constant. If you want to change the value of PI, you'll have to change the value of some integers, because of PI is defined by a number of formulas that depend only on natural numbers, for example:

    PI = 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ...

    see http://en.wikipedia.org/wiki/Pi for more formulas of the same kind.

    Nope, Pi is the ratio of circumference and diameter of a circle and that can change. The numeric methods to calculate it you mention are only valid in an Euclidean space. So yes there is conceivably a time and place where it was 3.0.

    Obvious troll is obvious. 1/10

  • (cs) in reply to Infinite Time and Space
    Infinite Time and Space:
    lanmind:
    TGV:
    you either take the Bible literally, or you don't.

    Wrong. Try again.

    Could be right, could be wrong. Depends if it is an AND or OR condition. If it is an AND condition, then you either take the entire bible literally, or if you take part literally and port not, then you do NOT take the bible literally. If it is on OR condition, then if you take any part of the bible literally, then you take the bible literally.

    XOR means you worship Satan, but not literally.

    +1

  • Tud (unregistered) in reply to Vitus
    Vitus:
    Nope, Pi is the ratio of circumference and diameter of a circle and that can change. The numeric methods to calculate it you mention are only valid in an Euclidean space. So yes there is conceivably a time and place where it was 3.0.
    Vitus:
    Wrong. Pi is dependent on the curvature of space. In a largely flat space it is what we measure it to be. In a rather curved space you will find it smaller or bigger depending on the type of curvature. In the early universe it would have been much smaller so there was a time when it was 3.
    const real MATHEMATICAL_CONSTANT_1 := 4/1 - 4/3 + 4/5 - 4/7 + 4/9 - 4/11 + ... = 3.1415926535897932384...
    const real GEOMETRICAL_CONSTANT_1 := euclidean_geometry.NewCircle().circumference / euclidean_geometry.NewCircle().radius = 3.1415926535897932384...
    const real PHYSICAL_CONSTANT_1 := current_universe.drawCircle().circumference / current_universe.drawCircle().radius = 3.1415926535897932384...
    if (current_universe.getGeometry == euclidean_geometry)
    {
       assert MATHEMATICAL_CONSTANT_1 == GEOMETRICAL_CONSTANT_1 == PHYSICAL_CONSTANT_1
    }
    

    And since they're the same, we just call that value "Pi".

  • Slugs (unregistered) in reply to justsomedude

    N is force, which the measure of weight. g is a measure of mass. 1 kg weighs ~ 9.81 N. You apparently failed physics.

  • Zany (unregistered)

    The boolean_table needs to support plugins, so I can extend it with "HappyHour" and "OnASunnyDay"

  • geekforgod (unregistered)

    I just wanted to show another possibility for the Biblical value of pi.

    In 1 Kings 7:23 the molten sea is said to be 10 cubits from one brim to the other and 30 cubits in circumference.

    If you notice in verse 26, however this object is a hand breadth thick. It is possible the 30 cubits circumference is of the inner circle instead of the outer and the 10 cubits is from outer rim to outer rim.

    According to google a cubit is 18 inches.

    According to wikipedia a handbreadth is 4 inches.

    So if we substitute

    2 * 3.14 * ((10 * 18) - 8)/2 = 30(18) 2 * 3.14 * 86 = 540 540.08 = 540

    That value is not exact, but it sure looks close enough for me.

  • Spewin Coffee (unregistered)

    Fil was such a great guy. Lots of people denied his existence and even spelled his name wrong on many occasions in mockery ("file", we're looking at you), but those who loved him write functions in his honor and encapsulate his memories within the integerized booleans of unnecessarily verbose programs. After all, love makes the hearts of programmers do crazy things.

    Fil, we'll miss you. Okay, now who wants some of this SHEEIT cake and PI?

Leave a comment on “The Object Test, a New PI, and More SHEEIT”

Log In or post as a guest

Replying to comment #:

« Return to Article