D - DDJ article quibble wrt nan
- Ben Hinkle (12/12) Feb 14 2004 The DDJ article is very nice (it shows off invariants, slicing, template...
- Matthew (8/17) Feb 18 2004 that I
- Bastiaan Veelo (4/19) Feb 19 2004 The magazine arrived in my Norwegian mailbox today :-)
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
Feb 14 2004
"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 typosthat Ihope 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 itwon't workfor floating point types (the sum will always be nan).Sorry about that.Kindof ironic this topic just came up recently about initializing floatswithnan. The template-less version using int *does* initialize explicitly with0. Indeed. :)
Feb 18 2004
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. ;-) -BenThe magazine arrived in my Norwegian mailbox today :-) In listing 6, ar[i] looks like it should be t. Bastiaan.
Feb 19 2004