Thread overview | |||||
---|---|---|---|---|---|
|
February 14, 2004 DDJ article quibble wrt nan | ||||
---|---|---|---|---|
| ||||
The DDJ article is very nice (it shows off invariants, slicing, templates, op-overloading, exceptions), but I noticed listing 13 had a couple typos that I hope don't confuse people. 1) the template type V looks like it should be a T. 2) the int in the foreach looks like it should be an R. 3) the sum variable has type R but uses the default initializer so it won't work for floating point types (the sum will always be nan). Kindof ironic this topic just came up recently about initializing floats with nan. The template-less version using int *does* initialize explicitly with 0. If you don't know what listing 13 is buy a copy of the magazine - heck buy two. ;-) -Ben |
February 19, 2004 Re: DDJ article quibble wrt nan | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | "Ben Hinkle" <bhinkle4@juno.com> wrote in message news:c0l9mj$3uf$1@digitaldaemon.com... > The DDJ article is very nice (it shows off invariants, slicing, templates, op-overloading, exceptions), but I noticed listing 13 had a couple typos that I > hope don't confuse people. > 1) the template type V looks like it should be a T. > 2) the int in the foreach looks like it should be an R. > 3) the sum variable has type R but uses the default initializer so it won't work > for floating point types (the sum will always be nan). Sorry about that. > Kindof ironic this topic just came up recently about initializing floats with > nan. The template-less version using int *does* initialize explicitly with 0. Indeed. :) |
February 19, 2004 Re: DDJ article quibble wrt nan | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ben Hinkle | Ben Hinkle wrote:
> The DDJ article is very nice (it shows off invariants, slicing, templates,
> op-overloading, exceptions), but I noticed listing 13 had a couple typos that I
> hope don't confuse people.
> 1) the template type V looks like it should be a T.
> 2) the int in the foreach looks like it should be an R.
> 3) the sum variable has type R but uses the default initializer so it won't work
> for floating point types (the sum will always be nan).
>
> Kindof ironic this topic just came up recently about initializing floats with
> nan. The template-less version using int *does* initialize explicitly with 0.
>
> If you don't know what listing 13 is buy a copy of the magazine - heck buy two.
> ;-)
>
> -Ben
The magazine arrived in my Norwegian mailbox today :-)
In listing 6, ar[i] looks like it should be t.
Bastiaan.
|
Copyright © 1999-2021 by the D Language Foundation