How many elements in a CASE ?
|
02-24-2016, 07:53 AM
Post: #8
|
|||
|
|||
RE: How many elements in a CASE ?
Hello,
Case will involve a lot of tests (all the tests needs to be tested one at a time)... and this can be quite slow for byte 255.... A better approach would be to check bit 7, 6, 5... in row. Note that you can use var(index) access on integers to extract a single bit! This would 1: change your case(256) to a series of if/then/else and lead to a consistent 8 tests per instruction. Or, you could have your evaluation code for instruction n be called Ins_n and then do an expr("Ins_"+n+"(parameters if needed)"); This would replace your 256 long case by a single line and would be much faster than the case. I am not sure if it would be faster than the 8 tests solution. You can also use a list (l) that contains the code for each of the instructions and do eval(l(instruction)). Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
How many elements in a CASE ? - smp - 02-22-2016, 12:18 PM
RE: How many elements in a CASE ? - Didier Lachieze - 02-22-2016, 02:49 PM
RE: How many elements in a CASE ? - smp - 02-22-2016, 11:02 PM
RE: How many elements in a CASE ? - cyrille de brébisson - 02-23-2016, 07:03 AM
RE: How many elements in a CASE ? - smp - 02-23-2016, 08:25 PM
RE: How many elements in a CASE ? - Tim Wessman - 02-23-2016, 09:14 PM
RE: How many elements in a CASE ? - smp - 02-23-2016, 11:31 PM
RE: How many elements in a CASE ? - cyrille de brébisson - 02-24-2016 07:53 AM
RE: How many elements in a CASE ? - smp - 02-24-2016, 12:40 PM
RE: How many elements in a CASE ? - smp - 02-29-2016, 01:40 AM
RE: How many elements in a CASE ? - debrouxl - 02-25-2016, 07:08 AM
RE: How many elements in a CASE ? - cyrille de brébisson - 02-26-2016, 06:49 AM
|
User(s) browsing this thread: 1 Guest(s)