I don't think its reasonable to call something as a cyclic data type when it
is not intended to be. Its just that the data type shows cyclic behaviour
due to size limit. Its not a feature.

float does not show this behaviour because its probably unable to handle
more than 7 significant digits. So, when you add 1 to it, the binary form
remains the same. Lets say you have "float x = 2", and you keep doing x* =
2. Though I didn't try it, I am sure the exponent part of float will
overflow eventually and hence, this will show cyclic behaviour. On a side
note, the example you showed is a perfect example to why people should not
use float for integer calculations :).

-Bharath

On 4 August 2010 11:06, Bartholomew Furrow <[email protected]> wrote:

> There is no such thing as cyclic data type. Its just that every data type
>> has limited size (1 byte for unsigned char).
>
>
> I think it's reasonable to talk about a cyclic data type -- it isn't a
> standard term as far as I know, but certainly there are data types that
> cycle under incrementation (char, int, long long, short, etc.) and data
> types that don't (float, double).
>
> float x = 16777216.0
> if (x == x + 1) {
>   printf("What?\n");
> }
>
> ...will print "What?".
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-code%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to