[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: programing error
From: |
Pascal Bourguignon |
Subject: |
Re: programing error |
Date: |
Sun, 28 Aug 2005 03:01:53 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
Baloff <washdc@wash.edu> writes:
> Hello
>
> coding in C++, I have a linked list to store int, but when I store
> double it is not working and I tried to find out why but could not,
>
> thanks for looking at this problem
>
> output************************************************************
> @debian:~/Exercies/ThinkingInC++/Vol1/4thCh/7$ ./proj1
> dblStash.fetch(0) = 0
> dblStash.fetch(1) = 1
> dblStash.fetch(2) = 2
> dblStash.fetch(3) = 3
> dblStash.fetch(4) = 4
> freeing storage
> @debian:~/Exercies/ThinkingInC++/Vol1/4thCh/7$ ./proj1
> dblStash.fetch(0) = 1.6976e-313
> dblStash.fetch(1) = 1.6976e-313
> dblStash.fetch(2) = 1.6976e-313
> dblStash.fetch(3) = 1.6976e-313
> dblStash.fetch(4) = 1.6976e-313
> freeing storage
> @debian:~/Exercies/ThinkingInC++/Vol1/4thCh/7$
You need to put doubles into the list if you want to get doubles out of it!
This is the standard GIGO principle: garbage in, garbage out.
> dblStash.add(&i);
Replace with:
double d=(double)i;
dblStash.add(&d);
--
__Pascal Bourguignon__ http://www.informatimago.com/
In deep sleep hear sound,
Cat vomit hairball somewhere.
Will find in morning.