pointless mathematical exercise

General development discussion.

Moderators: Susan Smith, admin, Gabriel

Post Reply
Gabriel
Posts: 412
Joined: Sun Aug 10, 2008 7:37 am
Location: Arlington, TX
Contact:

pointless mathematical exercise

Post by Gabriel »

Sometimes you do something exciting but pointless and nobody in the world save 20 odd people can appreciate or understand it but you have to share it anyway so here you go, my dear 20 colleagues.

BR 4.2 significantly increased the limits for workstack values. Before that the limit was 65535 bytes and if you use a lot of deeply embedded library functions you quickly run into this limit.

If you tried to set a workstack higher then 65535, you wouldn't get an error.. the workstack you ended up with would be the remainder of the workstack you specified after it was divided by 65536. For example, a workstack of 65536 would result in 0, 65537 would result in 1, 65538 would become 2 and so on, all the way up to 131071 which would result in 65535 again, and 131072 which would loop again back around to 0.

I often wondered why they never instituted an error and instead dealt with invalid numbers in this slightly confusing manner. But now I understand the usefulness of it.

I was trying to increase the workstack to take advantage of the new limits in 4.2 which are over 1,000,000 bytes, but I wanted it to still work under BR 4.1. So I came up with the following numbers, that work in both BR 4.2 and BR 4.1:

Code: Select all

WORKSTACK 983039
RPNSTACK 262143
FLOWSTACK 262143
FORSTACK 131071
These numbers all result in a stack of 65535 (the max) under BR 4.1 and a significantly higher stack (their actual values) under BR 4.2.

I could have made them all 983039 but I didn't want to use an additional 4MB of memory right off the top, and you really only need a large number for Workstack. In my experience, the other stacks don't get used nearly as much as the workstack does.

Anyway, there it is, my useless mathematical exercise for the day. I hope you all enjoyed this exciting foray into the forests of unnecessary logic.

Gabriel
Post Reply