Overflow flag

20 views
Skip to first unread message

Demetris Tziambazis

unread,
Mar 2, 2015, 4:00:52 AM3/2/15
to libfi...@googlegroups.com
 In the file fixmatrix.h of libfixmath the following is written:

 * This library does not do saturating arithmetic, but it does
 * feature an overflow flag for detecting erroneous results.

 * Error handling is done using flags in the matrix structure.
 * This makes it easy to detect if any errors occurred in any of
 * the computations, without checking a return status from each
 * function.

That means if i understand correctly that if an overflow is occurred in a function that i use a flag is raised.

How can I see that? How can I get an error/pop-up/notification that an overflow occurred?

Petteri Aimonen

unread,
Mar 2, 2015, 4:31:00 AM3/2/15
to libfi...@googlegroups.com
Hi,

> How can I see that? How can I get an error/pop-up/notification that an
> overflow occurred?

Check the 'errors' member in your result matrix:
https://github.com/PetteriAimonen/libfixmatrix/blob/master/fixmatrix.h#L40

--
Petteri

Demetris Tziambazis

unread,
Mar 2, 2015, 4:43:04 AM3/2/15
to libfi...@googlegroups.com
silly ( blind and newbie ) me!!

so each time i have to print the errors member of the current matrix to see if anything happend right??
and the results of error member will be the ones stated in the header file....
#define FIXMATRIX_OVERFLOW 0x01 #define FIXMATRIX_DIMERR 0x02
#define FIXMATRIX_USEERR 0x04
#define FIXMATRIX_SINGULAR 0x08
#define FIXMATRIX_NEGATIVE 0x10

Thank you Petteri!! :)

Petteri Aimonen

unread,
Mar 2, 2015, 4:51:02 AM3/2/15
to libfi...@googlegroups.com
Hi,

> so each time i have to print the errors member of the current matrix to see
> if anything happend right??

Yeah. Though the premade print function already does that:
https://github.com/PetteriAimonen/libfixmatrix/blob/master/fixstring.c#L20

> and the results of error member will be the ones stated in the header
> file....

Or a combination of them.

--
Petteri

Demetris Tziambazis

unread,
Mar 2, 2015, 5:12:58 AM3/2/15
to libfi...@googlegroups.com
I already made my one and made it print the error too but I would love to know what is the stream pointer in the print function? 

What does it pointing at?

Petteri Aimonen

unread,
Mar 2, 2015, 5:16:17 AM3/2/15
to libfi...@googlegroups.com
Hi,

> I already made my one and made it print the error too but I would love to
> know what is the stream pointer in the print function?

Normal fprintf() stream pointer, standard C. Depends on your libc what
you can make it point to, i.e. files, serial ports, whatever.

--
Petteri

Demetris Tziambazis

unread,
Mar 2, 2015, 5:26:46 AM3/2/15
to libfi...@googlegroups.com
Didnt even knew what a stream pointer was!!! --> http://stackoverflow.com/questions/4627330/difference-between-fprintf-printf-and-sprintf

Thank you again Petteri!! Be well and have a lovely day!

Demetris Tziambazis

unread,
Mar 2, 2015, 6:06:27 AM3/2/15
to libfi...@googlegroups.com
What is error number 9?

MATRIX ERRORS: 9
   0.0000    1.3990   -2.3174 
   0.0000    0.2870   -0.9234 
   0.0000    7.7266    8.0255 
Reply all
Reply to author
Forward
0 new messages