On Monday, 20 August 2012 at 19:28:33 UTC, Peter Alexander wrote:
[cut]
The problem is that it's easy for even NaN's to be filtered out.
float x = 0.0f;
float y; // oops
float z = min(x, y); // NaN has disappeared, unnoticed!
In theory, one could prevent this by setting the floating point
On 20/08/12 22:21, cal wrote:
On Monday, 20 August 2012 at 19:28:33 UTC, Peter Alexander wrote:
On Sunday, 19 August 2012 at 22:22:28 UTC, Walter Bright wrote:
I find it more likely that the NaN will go unnoticed and
cause rare bugs.
NaNs in your output are pretty obvious. For example, if
On 08/20/2012 11:09 AM, Andrej Mitrovic wrote:
On 8/20/12, Walter Brightnewshou...@digitalmars.com wrote:
On 8/19/2012 6:33 PM, Chad J wrote:
How? I remember reading a lot of material on NaNs in D, but I don't
recall these.
Set the control word for the x87 to turn it on. Probably have to
On Tuesday, 21 August 2012 at 08:15:10 UTC, Don Clugston wrote:
No, it's the other way around.
The IEEE 754 standard defines min(x, NaN) == min(NaN, x) == x.
According to the C standard, fmin() should be returning 10, as
well.
There is a bug in fmin().
However min() and max() are extremely
On 8/20/2012 12:41 AM, Nick Sabalausky wrote:
On Sun, 19 Aug 2012 01:21:03 -0500
Sean Cavanaughworksonmymach...@gmail.com wrote:
Nobody knows how floats work, without being locked in a closet for a
at least a week and told to change their doubles back into floats and
fix their code, since
On 18/08/12 05:03, bearophile wrote:
F i L:
Why would it matter what is normal?
It matters to me because I am curious.
Why aren't my friends that work or study chemistry writing free small
online articles like my programmerCS friends do? Maybe it's systematic
differences in their brain
Walter Bright, el 18 de August a las 12:11 me escribiste:
On 8/18/2012 6:51 AM, Peter Alexander wrote:
Maybe it's related to the tendency for programmers to be libertarians, which
would also explain the whole open source software movement. They want to
share
knowledge freely, and online
Any chance that math.isNaN() will work at compile-time in the future?
http://d.puremagic.com/issues/show_bug.cgi?id=8562
I haven't had the chance to study the source since last night, but is it
not possible to check to see if something is a nan without doing a cast?
On Fri, Aug 17, 2012 at 7:03
On 8/20/12, Walter Bright newshou...@digitalmars.com wrote:
On 8/19/2012 6:33 PM, Chad J wrote:
How? I remember reading a lot of material on NaNs in D, but I don't
recall these.
Set the control word for the x87 to turn it on. Probably have to do a little
inline assembly.
I thought you
On Sunday, 19 August 2012 at 22:22:28 UTC, Walter Bright wrote:
I find it more likely that the NaN will go unnoticed and
cause rare bugs.
NaNs in your output are pretty obvious. For example, if your
accounting program prints NAN for the amount on the payroll
cheques, someone is guaranteed
On Monday, 20 August 2012 at 19:28:33 UTC, Peter Alexander wrote:
On Sunday, 19 August 2012 at 22:22:28 UTC, Walter Bright wrote:
I find it more likely that the NaN will go unnoticed and
cause rare bugs.
NaNs in your output are pretty obvious. For example, if your
accounting program prints
On Monday, 20 August 2012 at 20:21:12 UTC, cal wrote:
I just tried this:
float a, b = 10;
writeln(min(a, b), , , fmin(a, b));
Result:
nan, 10
I think that is incorrect - both should give NaN. The
scientific viz software I use at work returns NaN for any
numerical operation on NaN values,
Peter Alexander:
It's tricky. The only way (that I'm aware of) to get it to
return NaN is to explicitly test for NaN, introducing overhead
that is unnecessary 99.9% of the time.
Unfortunately this is one of those situations where D's design
goals of efficiency and safety are at odds. You
On 8/18/2012 9:05 PM, Nick Sabalausky wrote:
No offense taken (or intended), but I think you're conflating the
different branches of the discussion.
I'm glad. And it's entirely likely that I missed something. I didn't
read the whole thread, I was just replying to your one message. Lazy...
On 8/18/2012 9:21 PM, Nick Sabalausky wrote:
After actually *using* both D (default-initialization) and C#
(statically/conservatively ensure things can't be accessed without
being explicitly inited), and I'm convinced the benefits of the static
checks easily outweigh the fear of a knee-jerk =0.
On 8/18/2012 9:33 PM, Nick Sabalausky wrote:
It sounds like it's some EE joke, but yea, strange as it seems, not
only is there really a Don't care, but it's actually useful
Yup, it turns out that all 4 states are very useful.
On 8/19/2012 12:12 AM, dennis luehring wrote:
Am 19.08.2012 06:12, schrieb Jonathan M Davis:
On Friday, August 17, 2012 17:03:13 Walter Bright wrote:
Our discussion on this in the last few days inspired me to write a
blog post
about it:
On 8/18/2012 11:21 PM, Sean Cavanaugh wrote:
Nobody knows how floats work, without being locked in a closet for a at least a
week and told to change their doubles back into floats and fix their code, since
thats where 99% of precision problems actually come from.
I was forced to figure out
On Sunday, 19 August 2012 at 05:13:09 UTC, dennis luehring wrote:
Am 19.08.2012 06:12, schrieb Jonathan M Davis:
On Friday, August 17, 2012 17:03:13 Walter Bright wrote:
Our discussion on this in the last few days inspired me to
write a blog post
about it:
On 2012-08-19 05:54:49 +, Walter Bright newshou...@digitalmars.com said:
On 8/18/2012 9:21 PM, Nick Sabalausky wrote:
After actually *using* both D (default-initialization) and C#
(statically/conservatively ensure things can't be accessed without
being explicitly inited), and I'm convinced
On Sunday, 19 August 2012 at 14:14:00 UTC, Michel Fortin wrote:
On 2012-08-19 05:54:49 +, Walter Bright
newshou...@digitalmars.com said:
On 8/18/2012 9:21 PM, Nick Sabalausky wrote:
After actually *using* both D (default-initialization) and C#
(statically/conservatively ensure things
On 8/19/2012 4:48 AM, Peter Alexander wrote:
Yes, I got this impression as well. What a sad state of affairs.
Yup. NaNs just don't get no respect, I tell ya! No respect at all!
On 08/17/2012 08:03 PM, Walter Bright wrote:
Our discussion on this in the last few days inspired me to write a blog
post about it:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_respect/
http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723
Walter, I
Walter Bright wrote in message news:k0rhp5$2fud$2...@digitalmars.com...
On 8/19/2012 4:48 AM, Peter Alexander wrote:
Yes, I got this impression as well. What a sad state of affairs.
Yup. NaNs just don't get no respect, I tell ya! No respect at all!
NaNs are the Rodney Dangerfield of D...
On Sun, 19 Aug 2012 22:18:37 +0200, Walter Bright
newshou...@digitalmars.com wrote:
On 8/19/2012 5:08 AM, bearophile wrote:
With a different type system the compiler makes sure at compile-time
that x is
not empty (this means the compiler makes sure in no code paths x is
used before
On Sun, 19 Aug 2012 05:52:01 +0200, Walter Bright
newshou...@digitalmars.com wrote:
On 8/18/2012 8:31 PM, Adam D. Ruppe wrote:
enum BOOL {
TRUE,
FALSE,
FILE_NOT_FOUND
}
I used to work with digital electronics. There, boolean logic actually
had 4 states:
True
False
On Sun, 19 Aug 2012 14:08:17 +0200, bearophile bearophileh...@lycos.com
wrote:
Walter Bright:
Oh come on. That's called a user defined type.
This D code compiles and it throws an Enforcement failed Exception at
runtime:
import std.typecons: Nullable;
void main() {
Nullable!int x;
On 8/19/2012 2:41 PM, Simen Kjaeraas wrote:
Nullable!int a;
int x = a; // Compile-time error: a might be null!
if ( a ) {
int y = a; // 's fine, we know it's not null.
}
You'd want the int to be the non-nullable type. You can do this with D's type
system. Each state would be a different
On 8/19/2012 1:43 PM, Chad J wrote:
So instead of writing
float f;
if (condition1)
f = 7;
... code ...
if (condition2)
++f;
is there any way we can make it easier to write
void someCode() {
... code ...
}
float f;
if (
On 8/19/2012 8:18 AM, Peter Alexander wrote:
Personally, I'd prefer option 1. Walter's argument is that this leads to the
programmer getting annoyed with false positive error diagnostics, and he'll
likely add an =0, which is true, but in my opinion this scenario is quite rare
to start with, and
I was against nan being the dafault value, but now I that I think
about it, it is useful (for the reasons in the article).
On 08/19/2012 06:16 PM, Walter Bright wrote:
On 8/19/2012 1:43 PM, Chad J wrote:
So instead of writing
float f;
if (condition1)
f = 7;
... code ...
if (condition2)
++f;
is there any way we can make it easier to write
void someCode() {
... code ...
}
float f;
if ( condition )
{
f = 7;
On 8/19/2012 6:33 PM, Chad J wrote:
How? I remember reading a lot of material on NaNs in D, but I don't recall
these.
Set the control word for the x87 to turn it on. Probably have to do a little
inline assembly.
On Sun, 19 Aug 2012 01:21:03 -0500
Sean Cavanaugh worksonmymach...@gmail.com wrote:
Nobody knows how floats work, without being locked in a closet for a
at least a week and told to change their doubles back into floats and
fix their code, since thats where 99% of precision problems actually
F i L:
It's flawed because condition2 relies upon condition1 to
Some people suggest:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_respect/c5uzt46
Regarding that Reddit thread in general, most people there seem
quite ignorant about NaNs, so this little article was
On Saturday, 18 August 2012 at 14:29:12 UTC, Jesse Phillips wrote:
On Saturday, 18 August 2012 at 09:32:01 UTC, F i L wrote:
It's flawed because condition2 relies upon condition1 to
function without error. The example, as Walter presented it,
is logically describing:
float f;
if
On 8/18/2012 6:51 AM, Peter Alexander wrote:
Maybe it's related to the tendency for programmers to be libertarians, which
would also explain the whole open source software movement. They want to share
knowledge freely, and online articles would be part of that.
I find this peculiar, as the
On Saturday, 18 August 2012 at 18:06:12 UTC, F i L wrote:
If the compiler warned against this error the programmer would
likely fix the code to a state which prevents the potential bug
this example was originally intended to illustrate.
It is this statement that indicates you didn't fully
Another sub-thread that shows a very important thing, that's
missing:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_respect/c5v1u0y
Bye,
bearophile
On 8/17/12 8:03 PM, Walter Bright wrote:
Our discussion on this in the last few days inspired me to write a blog
post about it:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_respect/
Homerun. Nice!!
Andrei
On Sat, 18 Aug 2012 23:12:10 +0200
Jesse Phillips jessekphillip...@gmail.com wrote:
On Saturday, 18 August 2012 at 18:06:12 UTC, F i L wrote:
If the compiler warned against this error the programmer would
likely fix the code to a state which prevents the potential bug
this example was
On Sat, 18 Aug 2012 06:44:12 +0200
Jesse Phillips jessekphillip...@gmail.com wrote:
On Saturday, 18 August 2012 at 01:07:43 UTC, F i L wrote:
Your example:
float f;
if (condition1)
f = 7;
... code ...
if (condition2)
++f;
is flawed in that
On 8/18/2012 7:36 PM, Nick Sabalausky wrote:
If that's the case, then the code is far too damn fragile in the first
place.
This:
float f;
if (condition1)
f = 7;
Is bad fucking code, period. I'd expect *ANY* usage of f after that
(except, of course, a plain assignment to it)
OT:
On Sunday, 19 August 2012 at 03:16:39 UTC, Davidson Corry wrote:
For that matter, wouldn't it be nice to have a Boolean NaN?
(not true, not false, but not yet decided)
enum BOOL {
TRUE,
FALSE,
FILE_NOT_FOUND
}
http://thedailywtf.com/Articles/What_Is_Truth_0x3f_.aspx
On 8/18/2012 2:16 PM, bearophile wrote:
Another sub-thread that shows a very important thing, that's missing:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_respect/c5v1u0y
Oh come on. That's called a user defined type.
struct OptionType {
private T m_value;
On 8/18/2012 7:27 PM, Nick Sabalausky wrote:
Bullshit, I've used C# which does exactly what Walter is arguing
against, and the result never involved getting annoyed and blindly
tossing in an =0.
I've seen this problem in the real world, even though you don't make such
mistakes.
On 8/18/2012 8:31 PM, Adam D. Ruppe wrote:
enum BOOL {
TRUE,
FALSE,
FILE_NOT_FOUND
}
I used to work with digital electronics. There, boolean logic actually had 4
states:
True
False
Don't Know
Don't Care
On Sat, 18 Aug 2012 20:16:37 -0700
Davidson Corry davidsonco...@comcast.net wrote:
On 8/18/2012 7:36 PM, Nick Sabalausky wrote:
If that's the case, then the code is far too damn fragile in the
first place.
This:
float f;
if (condition1)
f = 7;
Is bad
On Friday, August 17, 2012 17:03:13 Walter Bright wrote:
Our discussion on this in the last few days inspired me to write a blog post
about it:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_res
pect/
On Sat, 18 Aug 2012 20:44:52 -0700
Walter Bright newshou...@digitalmars.com wrote:
On 8/18/2012 7:27 PM, Nick Sabalausky wrote:
Bullshit, I've used C# which does exactly what Walter is arguing
against, and the result never involved getting annoyed and blindly
tossing in an =0.
I've seen
On Sat, 18 Aug 2012 20:52:01 -0700
Walter Bright newshou...@digitalmars.com wrote:
On 8/18/2012 8:31 PM, Adam D. Ruppe wrote:
enum BOOL {
TRUE,
FALSE,
FILE_NOT_FOUND
}
Heh, that's probably the #1 classic Daily WTF :)
I used to work with digital electronics. There,
On Sat, 18 Aug 2012 21:12:33 -0700
Jonathan M Davis jmdavisp...@gmx.com wrote:
FWIW, I'm very surprised by how negatively many programmers seem to
react to NaN. I think that how D handles it is great.
Yea, it's kind of like Unicode: ASCII is much simpler and therefore far
more enticing. But
Am 19.08.2012 06:12, schrieb Jonathan M Davis:
On Friday, August 17, 2012 17:03:13 Walter Bright wrote:
Our discussion on this in the last few days inspired me to write a blog post
about it:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_res
pect/
Our discussion on this in the last few days inspired me to write a blog post
about it:
http://www.reddit.com/r/programming/comments/yehz4/nans_just_dont_get_no_respect/
http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723
Walter Bright:
http://www.drdobbs.com/cpp/nans-just-dont-get-no-respect/240005723
You have omitted the detail that double.nan !is double.init.
On a more general note, I know many professionals in other fields
that never write small articles about what they are doing. So is
it normal just
Your example:
float f;
if (condition1)
f = 7;
... code ...
if (condition2)
++f;
is flawed in that condition1 is _required_ to pass in sync with
condition2, or you'll get a NaN in the result. In this scenario,
you're forced to provide a usable default explicitly
bearophile wrote:
On a more general note, I know many professionals in other
fields that never write small articles about what they are
doing. So is it normal just for programmers to write (small)
articles like this? I write them, and other programmers I know
write similar things. Maybe to
F i L:
Why would it matter what is normal?
It matters to me because I am curious.
Why aren't my friends that work or study chemistry writing free
small online articles like my programmerCS friends do? Maybe
it's systematic differences in their brain brain? Or it's just
more easy to talk
I remember you (Walter) or somebody else talking about signaling
NaNs before, but I don't remember many details about it. Does D
use them? Is this an answer to the Reddit commenter who mentioned
immediately throwing an exception?
On Saturday, 18 August 2012 at 01:07:43 UTC, F i L wrote:
Your example:
float f;
if (condition1)
f = 7;
... code ...
if (condition2)
++f;
is flawed in that condition1 is _required_ to pass in sync with
condition2, or you'll get a NaN in the result.
It is not
60 matches
Mail list logo