Posts: 544
Threads: 27
Joined: Jan 2005
O.K., Moneo, you have had a few responses. Now, what are you going to do with them? I envision you will cull them, arrange them in some order, with a nice description preceding each one, and sort of customize there presentation, besides providing a neat identifiction tag for each one. If that is your intention, it might be a good idea to let the folks know your intentions, publish what you have so far, and further invite more posts on the subject.
Regards,
Ralph
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Quote:O.K., Moneo, you have had a few responses. Now, what are you going to do with them? I envision you will cull them, arrange them in some order, with a nice description preceding each one, and sort of customize there presentation, besides providing a neat identifiction tag for each one. If that is your intention, it might be a good idea to let the folks know your intentions, publish what you have so far, and further invite more posts on the subject.
Regards,
Ralph
I revived this old thread for the purpose of correcting a rounding algorithm that I had posted back in 2003. I was concerned that someone might be using that old algorithm and sometimes getting wrong results while rounding negative numbers.
Then people started posting other algorithms, and the thread got started up again.
I already have a tutorial on algorithms which I wrote a few years ago for QBNZ. I might consider updating this tutorial for publication on the QB Express, in which case I'll scan this entire thread again to pick up any algorithms which in my opinion are worth including. This tutorial already gives credit to the author of each algorithm.
I agree with you had I intended to publish these algorithms. Yes, letting everyone know would have been a good idea. However, as I said before, this was not my intention. If you have the inclination to publish these algorithms, you're entirely free to do so.
*****
Posts: 484
Threads: 14
Joined: Apr 2005
Heres the plan
1. Ask for Algorithms.
2. ??????
3. Profit
EVEN MEN OF STEEL RUST.
Posts: 484
Threads: 14
Joined: Apr 2005
Heres a couple i came across recently that i found quite interesting. They are for testing if an addition or subtraction causes an overflow (ie the result is out of signed range)
These examples assume that a and b are 16-bit signed values. This can be changed by changing the AND &H8000 to other values (ie &H80 for 8-bit).
Here is a link to a topic where redcrab explained to me exactly how they work
http://www.freebasic.net/forum/viewtopic.php?t=3914
Addition
Code:
overflow = ((a XOR (NOT b)) AND (a XOR (a + b)) AND &H8000) <> 0
Subtraction
Code:
overflow = ((a XOR b) AND (a XOR (a - b)) AND &H8000) <> 0
EVEN MEN OF STEEL RUST.
Posts: 1,956
Threads: 65
Joined: Jun 2003
Vert good, Yetifoot, these algorithms for detecting overflow could come in handy for not having to use ON ERROR.
*****
Posts: 484
Threads: 14
Joined: Apr 2005
I think they would have to be modified for use in QB, because the code itself will cause an overflow (due to a+b, or a-b). They are more useful for FB, because FB does not do overflow checks (unless it's switched on with -ex, or -exx).
EVEN MEN OF STEEL RUST.
Posts: 1,407
Threads: 117
Joined: Dec 2002
QBasic does not signal overflow if compiled without the /d option. Only interpreted QB always signals overflows, and your code would fail there.
Antoni
Posts: 484
Threads: 14
Joined: Apr 2005
Quote:QBasic does not signal overflow if compiled without the /d option. Only interpreted QB always signals overflows, and your code would fail there.
Thanks for the clarification, I have not used QB/QBASIC much so I don't know much about it.
EVEN MEN OF STEEL RUST.