Is this a compiler problem?
Ok so my program is acting real weird.
Here's the output if I run in the debugger:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
Tests run: 5
Tests Failed: 0
Account Details
Number Type Value APR Tax Rate
5634 Mutual Fund 1000.00 -7%-25% 0.1%
4431 Bond 1000.00 6 % 0.0%
8604 Burried 1000.00 0% 0.0%
Mutual Fund Tax-Free Bond Buried
Year Infl. Value Yld Value Yld Value
1 3% 1002.98 0.3% 1028.20 2.8% 970.00
2 3% 914.52 -8.8% 1057.20 2.8% 940.90
3 3% 878.21 -4.0% 1087.01 2.8% 912.67
4 3% 859.11 -2.2% 1117.66 2.8% 885.29
5 3% 882.92 2.8% 1149.18 2.8% 858.73
6 3% 822.17 -6.9% 1181.59 2.8% 832.97
7 3% 824.62 0.3% 1214.91 2.8% 807.98
8 3% 743.89 -9.8% 1249.17 2.8% 783.74
9 3% 776.77 4.4% 1284.39 2.8% 760.23
10 3% 766.28 -1.4% 1320.61 2.8% 737.42
Mutual Fund Tax-Free Bond Burried
Yr Infl Avg Val Yld Avg Val Yld Val
1 2% 9821.30 -1.8% 10185.97 1.9% 9700.00
2 2% 9738.60 -0.8% 10477.93 2.9% 9506.00
3 2% 9506.20 -2.4% 10675.17 1.9% 9221.79
4 2% 9322.88 -1.9% 10875.80 1.9% 8945.15
5 2% 9207.78 -1.2% 11080.90 1.9% 8676.79
6 2% 9037.03 -1.9% 11290.60 1.9% 8416.49
7 2% 8818.25 -2.4% 11505.00 1.9% 8163.99
8 2% 8638.77 -2.0% 11724.22 1.9% 7919.07
9 2% 8418.85 -2.5% 11948.39 1.9% 7681.50
10 2% 8291.48 -1.5% 12177.62 1.9% 7451.06
| |
Notice how everything is lined up nice and pretty.
Now here's the output if I press run:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
Tests run: 5
Tests Failed: 0
Account Details
Number Type Value APR Tax Rate
2089 Mutual Fund 1000.00 -7%-25% 0.1%
729 Bond 1000.00 4 % 0.0%
410 Burried 1000.00 0% 0.0%
Mutual Fund Tax-Free Bond Buried
Year Infl. Value Yld Value Yld Value
1 3% 1019.47 1.9% 1008.80 0.9% 970.00
2 3% 939.44 -7.9% 1017.68 0.9% 940.90
3 3% 902.15 -4.0% 1026.63 0.9% 912.67
4 3% 897.40 -0.5% 1035.67 0.9% 885.29
5 3% 870.47 -3.0% 1044.78 0.9% 858.73
6 3% 894.60 2.8% 1053.98 0.9% 832.97
7 3% 807.02 -9.8% 1063.25 0.9% 807.98
8 3% 735.84 -8.8% 1072.61 0.9% 783.74
9 3% 762.30 3.6% 1082.05 0.9% 760.23
10 3% 739.43 -3.0% 1091.57 0.9% 737.42
Mutual Fund Tax-Free Bond Burried
Yr Infl Avg Val Yld Avg Val Yld Val
1 2% 9760.82 -2.4% 137995509868612070000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000.00 137995509868612070000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000.0% 9700.002 2% 9649.60 -1.1% 1379955
09868612070000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000.00 -99.0%
9506.003 2% 9483.52 -1.7% 1379955098686120700000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000.00 -99.0% 9221.794 2%
9248.12 -2.5% 137995509868612070000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000.00 -99.0% 8945.155 2% 9003.66 -2.6% 13799
55098686120800000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000.00 -99.0% 867
6.796 2% 8825.90 -2.0% 13799550986861209000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000.00 -99.0% 8416.497 2% 8698.99
-1.4% 1379955098686120800000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000.00
-99.0% 8163.998 2% 8514.26 -2.1% 137995509868612080000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000.00 -99.0% 7919.079 2%
8399.04 -1.4% 137995509868612090000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000.00
-99.0% 7681.5010 2% 8306.11 -1.1% 137995509868612
08000000000000000000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000.00 -99.0% 7451.06
Process returned 0 (0x0) execution time : 0.038 s
Press any key to continue.
| |
Any idea what would cause it to do that?
Possibilities that jump to mind:
1) Heap corruption (are you stepping outside some array bounds somewhere?)
2) Using uninitialized variables (are you expecting a variable to be initialized with 0 even though you never explicitly set it to 0?)
How about I didn't even touch the method that controls that output, but I added a new method and recompiled. Now it looks like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Tests run: 5
Tests Failed: 0
Account Details
Number Type Value APR Tax Rate
5324 Mutual Fund 1000.00 -7%-25% 0.1%
5235 Bond 1000.00 6 % 0.0%
7216 Burried 1000.00 0% 0.0%
Mutual Fund Tax-Free Bond Buried
Year Infl. Value Yld Value Yld Value
1 3% 1118.41 11.8% 1028.20 2.8% 970.00
2 3% 1130.96 1.1% 1057.20 2.8% 940.90
3 3% 1320.83 16.8% 1087.01 2.8% 912.67
4 3% 1390.11 5.2% 1117.66 2.8% 885.29
5 3% 1382.79 -0.5% 1149.18 2.8% 858.73
6 3% 1314.48 -4.9% 1181.59 2.8% 832.97
7 3% 1361.75 3.6% 1214.91 2.8% 807.98
8 3% 1444.40 6.1% 1249.17 2.8% 783.74
9 3% 1543.98 6.9% 1284.39 2.8% 760.23
10 3% 1437.75 -6.9% 1320.61 2.8% 737.42
After running the simulation 100 times, the best and worst accounts were:
BEST FUNDS
Number Type Principle End Value APR Tax Rate
4599 Mutual Fund 10000.00 24808.09 -7% - 25% 15%
6361 Bond 10000.00 13206.14 6% 0%
2467 Burried 10000.00 7374.24 0% 0%
WORST FUNDS
Number Type Principle End Value APR Tax Rate
6009 Mutual Fund 10000.00 6982.58 -7% - 25% 15%
2722 Bond 10000.00 10915.68 4% 0%
2467 Burried 10000.00 7374.24 0% 0%
Mutual Fund Tax-Free Bond Burried
Yr Infl Avg Val Yld Avg Val Yld Val
1 2% 10270.94 2.7% 10175.30 1.8% 9700.00
2 2% 10748.94 4.7% 10456.11 2.8% 9506.00
3 2% 11244.00 4.6% 10641.83 1.8% 9221.79
4 2% 11674.90 3.8% 10830.54 1.8% 8945.15
5 2% 12012.70 2.9% 11023.33 1.8% 8676.79
6 2% 12509.30 4.1% 11220.29 1.8% 8416.49
7 2% 12980.88 3.8% 11421.53 1.8% 8163.99
8 2% 13389.71 3.1% 11627.16 1.8% 7919.07
9 2% 13963.97 4.3% 11837.28 1.8% 7681.50
10 2% 14382.55 3.0% 12052.01 1.8% 7451.06
| |
Strange huh?
Irrelevent changes having an effect on program output smells of heap corruption. I stand by my earlier post.
Topic archived. No new replies allowed.