D
Dala Dahlgren
I am writing a program where I have a subroutine which adds up a number,
basically something like this;
int myNumber;
void add(int i){
myNumber=myNumber+i;
}
So everytime "add" is called myNumber increases.
My problem is that myNumber is "reset" or is definet as "infinity", even
though the number is not too large for the datatype used.
I have tried with a couple of different datatypes.
First I defined all my numbers as "double" since I don't only add integers.
But when myNumber is about 6000 it is suddenly set to #INF the next time it
increases.
I have also tried to define the numbers as pure integers ("long"), but now
the number is reset to 0 a little after it passes 600,000.
Both the 'double' and the 'long' datatypes should be able to handle larger
numbers than this. I am using Microsoft Developer Studio 97, on a Pentium 4
PC.
Can somebody tell me what my problem is and what I should do to be able to
add up more numbers?
Thanks...
basically something like this;
int myNumber;
void add(int i){
myNumber=myNumber+i;
}
So everytime "add" is called myNumber increases.
My problem is that myNumber is "reset" or is definet as "infinity", even
though the number is not too large for the datatype used.
I have tried with a couple of different datatypes.
First I defined all my numbers as "double" since I don't only add integers.
But when myNumber is about 6000 it is suddenly set to #INF the next time it
increases.
I have also tried to define the numbers as pure integers ("long"), but now
the number is reset to 0 a little after it passes 600,000.
Both the 'double' and the 'long' datatypes should be able to handle larger
numbers than this. I am using Microsoft Developer Studio 97, on a Pentium 4
PC.
Can somebody tell me what my problem is and what I should do to be able to
add up more numbers?
Thanks...