|
PhantomOfTheCopier posted:You people sure have some strange reading problems. Matlab is an application. It is perfectly reasonable for it to return calculations that adhere most closely to standard practice of significant digits. Nothing prevents and nothing I wrote prevents intermediate and internal calculation to be handled differently. Real number results are handled differently than integers (which I said nothing about). Nothing prevents an idiot with a computer programming language from specifically requesting the wrong value for 2pi. I'm sure some legislator would have been happy to have such an app. If you wanted to exclude integers from your argument then you should have said so. Regardless, your argument still applies to integer precision whether you like it or not, and the same counterarguments apply to downcasting floating point precision. It looks like everyone read your post very accurately, you're just upset that people don't agree with you. Further, did you read my post? Because I'm suggesting that it would be fine to downcast if Matlab at least threw a warning at the user telling them that it was doing so; then the intention of MathWorks is explicit when 2 different precision levels smash into each other instead of silently giving you less precision than you may have expected. Further, you're mixing up terms in order to try and give yourself a point that you didn't make initially; significant digits are not the same as numerical precision, and a number being written as float32 does not mean that its significance includes all of float32's precision range, nor does it mean that its significance is limited to that range (as an example, consider the number of significant digits to the number 1 when stored in float32; why does multiplying the float32 representation of 1 by a number using the entirety of float64 precision cause me to lose precision? Downcasting that result to float32 is in fact unreasonable) QuarkJets fucked around with this message at 08:28 on Sep 29, 2017 |
# ? Sep 29, 2017 08:21 |
|
|
# ? Jun 1, 2024 04:56 |
|
Eela6 posted:you're real dumb, hth He's double dumb, in fact.
|
# ? Sep 29, 2017 10:01 |
|
QuarkJets posted:If you wanted to exclude integers from your argument then you should have said so. Regardless, your argument still applies to integer precision whether you like it or not, and the same counterarguments apply to downcasting floating point precision. Without expressing any view on the rest of PhantomOfTheCopier's arguments, it doesn't seem to me that this is the case. "integer precision" really means range of representable values, not precision per se, whereas floating-point precision is precision per se. Given a range of integer values, there is only one possible degree of precision that we would expect to be made available by an integer data type supporting that range, which is to say: absolute precision. The argument that spurious precision should be avoided when dealing with floating-point numbers doesn't apply to integers, where the notion of spurious precision does not apply.
|
# ? Sep 29, 2017 10:33 |
|
QuarkJets posted:(as an example, consider the number of significant digits to the number 1 when stored in float32; why does multiplying the float32 representation of 1 by a number using the entirety of float64 precision cause me to lose precision? Downcasting that result to float32 is in fact unreasonable)
|
# ? Sep 29, 2017 13:30 |
|
TooMuchAbstraction posted:Let us never lose sight of the fact that Matlab is a terrible, awful programming language that only survives because it has so goddamn many scientific/mathematical libraries bolted onto it. And now it's tearing our happy thread apart. Truly its horror knows no bounds.
|
# ? Sep 29, 2017 14:01 |
|
I'm getting really confused here. The number 1.0, as a float32, precisely represents the real number 1, to as many decimal places as you want. Upcasting to float64 doesn't alter that. But at least two people in this thread have said the opposite.
|
# ? Sep 29, 2017 14:38 |
|
Doom Mathematic posted:I'm getting really confused here. The number 1.0, as a float32, precisely represents the real number 1, to as many decimal places as you want. Upcasting to float64 doesn't alter that. But at least two people in this thread have said the opposite. It's not about the decimal representation at all. What's the closest representable float to 1+2-50? What about the closest representable double?
|
# ? Sep 29, 2017 14:44 |
|
Jabor posted:It's not about the decimal representation at all. I don't know, what?
|
# ? Sep 29, 2017 14:47 |
|
A related question, that might make things easier to understand if you tackle it first: What's the smallest representable float that's bigger than 1.0?
|
# ? Sep 29, 2017 14:51 |
|
Doom Mathematic posted:I'm getting really confused here. The number 1.0, as a float32, precisely represents the real number 1, to as many decimal places as you want. Upcasting to float64 doesn't alter that. But at least two people in this thread have said the opposite. The point is that if the result of a calculation is the float32 1.0, that means that the "true answer" to the calculation was in a certain interval on the number line which includes the real number 1. If you then make it a float64 then it might appear to a consumer as though the "true answer" lies in a smaller interval (because float64 has greater precision than float32). Maybe it does, maybe it actually is a number which converted suitably into a float64 would end up as something other than 1.0.
|
# ? Sep 29, 2017 15:06 |
|
If you try to represent the number 1.0000000001 as a float32, it will be truncated to 1.0. If you then use that 1.0 to do perform operations with a float64, you will get a different answer than you would had you put 1.0000000001 in a float64 to begin with. If the result is a float64, you may think you've got the precision of a float64 when your precision is really only that of the float32 you started with, and any digits outside of that are spurious. That said, the solution to a programmer making such a mistake is still probably not to silently downcast to float32. Silently limiting the range of possible results and throwing away digits is not a good way to handle the fact that some of those digits might not be correct in some rare circumstances. And it's definitely always wrong when we're talking about integer types.
|
# ? Sep 29, 2017 15:09 |
|
The La Mulana 2 team posted an update on their progress:quote:At the beginning of development, we had planned to let Lumisa talk with all the NPCs by pressing a button when near them, but considering our code, it was very difficult to implement and we had to omit that. Instead, we changed the system to start the conversation automatically when Lumissa gets near those guide NPCs or enters the event area. I have no idea how code can be that inflexible, but what do I know.
|
# ? Sep 29, 2017 15:10 |
|
Pollyanna posted:The La Mulana 2 team posted an update on their progress: lol Kickstarted games are probably just automatic coding horrors
|
# ? Sep 29, 2017 15:18 |
|
That reminds me, someone put together a primer on the programming language Jonathan Blow has been making. I don't actually think it's a horror, though it is always a bit shocking to see the work of programmers in a sub-field with completely different demands and desires.
|
# ? Sep 29, 2017 15:55 |
|
We have a bunch of places in code where we want to switch on an enum and not miss any cases (I assume this is not wildly out of the ordinary). Until today I wasn't aware that MSVC supported this:code:
|
# ? Sep 29, 2017 16:10 |
|
code:
|
# ? Sep 29, 2017 16:58 |
|
CPColin posted:
Clipping off the hours, minutes, seconds, etc?
|
# ? Sep 29, 2017 17:06 |
|
Pollyanna posted:The La Mulana 2 team posted an update on their progress: My guess is that they have a problem with an underlying system that makes it difficult to identify which NPC is the one you're trying to interact with. Where, with their stated solution, to trigger a conversation whenever you are in range, they don't need to be specific, they can just grab every entity in a certain radius. I'm saying this with no information about the game itself. Munkeymon posted:lol Kickstarted games are probably just automatic coding horrors All games are coding horrors.
|
# ? Sep 29, 2017 17:13 |
|
CPColin posted:
What's the context for this? The datetime-to-string-to-datetime is real dumb, but I can forgive someone for not knowing about the Date property and coming up with an alternative (although this might break based on culture). Going by .NET naming conventions, FromDate, ToDate and DateWork are (public) properties, which seems to point to far more horrors.
|
# ? Sep 29, 2017 17:16 |
|
The Fool posted:All games are coding horrors. C code:
|
# ? Sep 29, 2017 17:20 |
|
PhantomOfTheCopier posted:You people sure have some strange reading problems. Matlab is an application. Hell, some of my own colleagues use it for chip design.
|
# ? Sep 29, 2017 17:30 |
|
Doom Mathematic posted:I'm getting really confused here. The number 1.0, as a float32, precisely represents the real number 1, to as many decimal places as you want. Upcasting to float64 doesn't alter that. But at least two people in this thread have said the opposite.
|
# ? Sep 29, 2017 17:30 |
|
Munkeymon posted:Clipping off the hours, minutes, seconds, etc? dwazegek posted:What's the context for this? Yeah, this is adjusting a value retrieved from a database, so stripping off the time portion is what I'm guessing, too. dwazegek posted:The datetime-to-string-to-datetime is real dumb, but I can forgive someone for not knowing about the Date property and coming up with an alternative (although this might break based on culture). That DateWork identifier is a local variable: code:
|
# ? Sep 29, 2017 17:32 |
|
Hammerite posted:We have a bunch of places in code where we want to switch on an enum and not miss any cases I've just done this in the last week; I moved the switch into its own method and then a unit test that checks for all enum values a non null object is returned and no exceptions are raised.
|
# ? Sep 29, 2017 17:35 |
|
Doc Hawkins posted:That reminds me, someone put together a primer on the programming language Jonathan Blow has been making. I like Jonathon Blow, I've been following his talks about the why and how of his programming language and I must say that the reasoning behind it is usually pretty good. He also makes it really easy to understand some fundamental issues with C++ and game engines in general. Especially the bit with the Structs of Arrays and Arrays of Structs and why you want only a subset of the properties of your classes, the ones that have transforms for example which get updated every frame, in a smaller data structure that can live in the CPU cache. Listening to the Unite 2017 talk about Unity3d and the implementation of its job system, reminded me of what he was talking about. Plus he makes me feel a better programmer because he does some live programming and you can see the mistakes he makes and the thinking process he goes through.
|
# ? Sep 29, 2017 17:56 |
|
PhantomOfTheCopier posted:The fact that a math focused application ensures results introduce no false precision is entirely reasonable and good. If x=pi is a single, y=pi is a double, then x+y can only ever be 2pi to the precision of a single. Returning x+y as a double is just wrong. code:
Zemyla posted:Clearly, we should represent all real values as lazy infinite continued-fraction lists. code:
quote:Integers... Jethro posted:That said, the solution to a programmer making such a mistake is still probably not to silently downcast to float32. Everyone enjoy their approximately (float)0.33*(length_of_day) of work today!
|
# ? Sep 29, 2017 18:01 |
|
quiggy posted:
That's no horror, that's just implementing Fast Inverse Square Root. The comments are an acceptable reaction to such sorcery. Edit: Oh hey, that's actually the Quake 3 code, on the wiki page. Ranzear fucked around with this message at 18:29 on Sep 29, 2017 |
# ? Sep 29, 2017 18:26 |
|
quiggy posted:
What I particularly hate about this is that it's still treated by many people as a legit optimization instead of a historical curiosity when: 1. There are much better ways to do this nowadays with compiler intrinsics. 2. It's actually illegal code in C++, which is what these coders are actually using.
|
# ? Sep 29, 2017 18:26 |
|
Aramis posted:2. It's actually illegal code in C++, which is what these coders are actually using. I am pretty sure it is illegal C, too. That cast from float pointer to long pointer is undefined behaviour. I seem to recall you need to use memcpy() for such tricks if you want your code to be legal.
|
# ? Sep 29, 2017 18:29 |
|
Athas posted:I am pretty sure it is illegal C, too. That cast from float pointer to long pointer is undefined behaviour. I seem to recall you need to use memcpy() for such tricks if you want your code to be legal. You can make it legal C using a union IIRC.
|
# ? Sep 29, 2017 18:30 |
|
More, from the same file:code:
|
# ? Sep 29, 2017 18:36 |
|
There are three types of programmers in the world. Those who make off-by-one errors and those who don't.
|
# ? Sep 29, 2017 18:38 |
|
CPColin posted:Yeah, this is adjusting a value retrieved from a database, so stripping off the time portion is what I'm guessing, too. What's wrong with using string.Empty instead of ""? Or an unneeded initialization? Seems pedantic to care about such things.
|
# ? Sep 29, 2017 18:39 |
|
I once wrote a unit test that dealt with time in the form of now vs a future date. Rather than making sure that future date was now + x months, I arbitrarily and lazily picked the month of june, because it was currently march. Imagine what happened in June.
|
# ? Sep 29, 2017 18:44 |
|
Eggnogium posted:What's wrong with using string.Empty instead of ""? Or an unneeded initialization? Seems pedantic to care about such things. string.Empty is more typing than "" and unneeded initialization makes the processor do more work than it needs to. Without the unneeded initialization, I wouldn't even have had to bring up the use of string.Empty and I wouldn't be typing this post! See how much waste it is?
|
# ? Sep 29, 2017 18:53 |
|
Aramis posted:You can make it legal C using a union IIRC. Yeah you could legally rewrite the cast in C/C++ with: C++ code:
|
# ? Sep 29, 2017 19:07 |
|
CPColin posted:string.Empty is more typing than "" and unneeded initialization makes the processor do more work than it needs to. Without the unneeded initialization, I wouldn't even have had to bring up the use of string.Empty and I wouldn't be typing this post! See how much waste it is? Yeah, but like, who cares? Half the stuff you've posted in this thread is so minor it just seems like you have a bug up your rear end. Do you actually get anything done obsessively grooming minor inefficiencies out of your code?
|
# ? Sep 29, 2017 19:12 |
|
Hello, welcome to the "Coding horrors" thread!
|
# ? Sep 29, 2017 19:14 |
|
It is very to start at a new place and start seeing stuff like that all over the place.
|
# ? Sep 29, 2017 19:16 |
|
|
# ? Jun 1, 2024 04:56 |
|
CPColin posted:Hello, welcome to the "Coding horrors" thread! caring about the processor doing a completely irrelevant amount of extra work is a coding horror
|
# ? Sep 29, 2017 19:17 |