home *** CD-ROM | disk | FTP | other *** search
- #if 0
- From: Scott Ladd
- Subject: ZTC Bug 35171
- Status: Fixed in 3.0b5
- #endif
-
- // compile this file with
- //
- // ztc -c -o slz3bug8.cpp
- //
- // and ZTC2B will crash with a ZTC Bug 35171
-
- typedef long Fixed;
-
- extern "C"
- {
- Fixed FixedAdd(Fixed f1, Fixed f2);
- Fixed FixedSub(Fixed f1, Fixed f2);
-
- Fixed FixedMul(Fixed f1, Fixed f2);
- Fixed FixedDiv(Fixed f1, Fixed f2);
-
- Fixed FixedAbs(Fixed ff);
-
- void FixedSet(unsigned char decpos);
-
- int FixedOut(char * buf, Fixed ff, unsigned char prec);
-
- Fixed FloatToFixed(float f);
- float FixedToFloat(Fixed f);
- }
-
- class FixedPoint
- {
- public:
- FixedPoint();
- FixedPoint(const FixedPoint & f);
- FixedPoint(float f);
-
- void operator = (const FixedPoint & f);
-
- friend FixedPoint operator - (FixedPoint f1,FixedPoint f2);
- friend FixedPoint operator / (FixedPoint f1,FixedPoint f2);
-
- protected:
- Fixed Value;
- };
-
- inline FixedPoint::FixedPoint()
- {
- Value = 0L;
- }
-
- inline FixedPoint::FixedPoint(const FixedPoint & f)
- {
- Value = f.Value;
- }
-
- inline FixedPoint::FixedPoint(float f)
- {
- Value = FloatToFixed(f);
- }
-
- inline void FixedPoint::operator = (const FixedPoint & f)
- {
- Value = f.Value;
- }
-
- inline FixedPoint operator - (FixedPoint f1, FixedPoint f2)
- {
- FixedPoint temp;
-
- temp.Value = FixedSub(f1.Value,f2.Value);
-
- return temp;
- }
-
- inline FixedPoint operator / (FixedPoint f1, FixedPoint f2)
- {
- FixedPoint temp;
-
- temp.Value = FixedDiv(f1.Value,f2.Value);
-
- return temp;
- }
-
- FixedPoint XMax, XMin, deltaX;
-
- int main()
- {
- XMax = 1.2F;
- XMin = -2.0F;
-
- deltaX = (XMax - XMin) / 256.0F;
-
- return 0;
- }
-