D - DDJ article quibble wrt nan
- "Ben Hinkle" <bhinkle4 juno.com> Feb 14 2004
- "Matthew" <matthew.hat stlsoft.dot.org> Feb 18 2004
- Bastiaan Veelo <Bastiaan.N.Veelo ntnu.no> Feb 19 2004
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 typos
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
for floating point types (the sum will always be nan).
Sorry about that.Kindof ironic this topic just came up recently about initializing floats
nan. The template-less version using int *does* initialize explicitly with
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. ;-) -Ben
The magazine arrived in my Norwegian mailbox today :-) In listing 6, ar[i] looks like it should be t. Bastiaan.
Feb 19 2004









"Matthew" <matthew.hat stlsoft.dot.org> 