swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

odd bug in Cygnus?


From: Doug Donalson
Subject: odd bug in Cygnus?
Date: Sat, 30 May 1998 18:10:54 -0700

In my quest to change X,Y coordinates into chars I ran into an odd type
cast
bug(?) in Cygnus/Win95.  Note: I have tried this on my Unix system and
it
works fine.  Also, I now have an alternate coding that works.

This code is ugly, but what do you expect from an engineer/ecologist?

int x=some coordinate;
double x1,x2;
double temp;
int newX1;

temp=(double)x/10;
x1=modf(temp,&x2);
newX1=(char)(x1*10);

For the digits 3 and 7 only, 3's are cast to 2's and 7's are cast to
6's.
If  your original number was 03 and you printf x1*10, you get
3.000000000,
but that is obviously not real.  It is in fact just very slightly less
than 3 because
if you add 0.01 to x1 prior to the (int), the type cast then works.  So
word of
warning, double->int cast has some potential error problems when using
Cygnus on Win95.  Again, I copied the code to a Unix machine and it
functioned
as I expected.

As Buffalo Springfield said: For what it's worth...

Doug



                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.
                  ==================================


reply via email to

[Prev in Thread] Current Thread [Next in Thread]