Casio fx-50F/fx-50FH programming
|
09-26-2019, 07:34 AM
(This post was last modified: 09-26-2019 07:36 AM by ijabbott.)
Post: #8
|
|||
|
|||
RE: Casio fx-50F/fx-50FH programming
(09-25-2019 04:22 PM)Csaba Tizedes Wrote: SIGN(var) on CASIO: (var>0)-(var<0) A similar trick can be used to determine the ordering of two numbers: \( (a > b) - (a < b) \) That yields -1, 0 or 1 depending on the ordering. That's what I usually do to calculate the return value for comparison functions for use with the qsort() (quicksort) function in the C programming language standard library. In that case, the comparison function is allowed to return any integer because only the sign is used to determine the sort order of its two parameters. But using the above trick avoids arithmetic overflow and works for both signed and unsigned numbers. It is easy enough to modify the expression to reverse the ordering. It doesn't necessarily generate the tightest binary code, but is pretty close to generating the tightest code, and it looks pretty. — Ian Abbott |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)