Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

PSoC™ 5, 3 & 1 Forum Discussions

Anonymous
Not applicable

Math errors on int64 and uint64
Using PSoC creator targeting PSoC5LP development kit

   

int32 math works fine. No errors found.

   

int64 or uint64 math fails with no errors at compile or runtime.

   

Example

   

uint64 i,j; // i = 1116621
j=i*1000000 // volts to microvolt

   

// now j evaluates to 18446744073639054656 or 
// 0xFFFFFFFFFBCC4D40
// this looks a lot like a 32bit overflow.
// why dont the compiler give an error if this is not implemented?

0 Likes
6 Replies
Anonymous
Not applicable

You are using constants without clarifiers. At least in the past this led to errors.

   

 

   

Ed

0 Likes
Anonymous
Not applicable

Any way you do it it fails.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

There was a known bug with displaying 64-bit integers with the debugger. Now corrected in actual version Creator 3.3. No known errors in math.lib.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

The error is not displaying 64 bit ints. I am sure there are no errors in math.lib. It appears more like int64 is simply implemented as int32 without further comment. Found workaround, and will not spend more time on it. Just a surprise.

0 Likes
Anonymous
Not applicable

I wanted to add to this thread ... this is a BUG!!

   

 

   

If we simply declare a unit64, and then - in a loop - OR in a value (e.g. AA) and shift <<8, then do this three times, the uint64 becomes:

   

0xFFFFFFFFAAAAAA00

   

​On that third shift there is an overflow and the upper two words become FFFFFFFF

   

#fail

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Can you please provide us with a complete project to verify the error? Creator->File->Create workspace bundle

   

 

   

Bob

0 Likes