- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Labels:
-
PSoC 5LP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You are using constants without clarifiers. At least in the past this led to errors.
Ed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Any way you do it it fails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you please provide us with a complete project to verify the error? Creator->File->Create workspace bundle
Bob