Weather / Spam / www |
Lyon Weather
aldweb against spam
|
|
|
|
|
|
|
- Forum - iziBasic
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 257
Topic # 1296 |
Proper way to Exit concole program |
23/11/2005 @ 21:45 by Richard
|
I have a simple little program that asks for a number and reports if it is a prime number.
Very simple version of the program
BEGIN
D0 INPUT "? ", K$ PRINT K$ GOSUB _ISPRIME IF P = 1 THEN PRINT " Prime" ELSE PRINT " Not Prime" END IF LOOP K$ = ""
END
Should I do anything prior to reaching the END statement?
Thanks,
Richard
PS: What is the maximum Positive Integer can iziBasic handle? Thanks
|
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 1 -------- 24/11/2005 @ 13:32 by aldweb
visitor |
Hello Richard,
Your source code should work very fine as is, there is nothing special to do before reaching the END statement. What did you think about? What is your reason for asking?
Numbers in iziBasic are 32 bit float IEEE 754 compatible. Typing "32 bit float IEEE 754" in any search engine like Google will give you thousands of pages to read about this standard. Here is one that answers your question: http://www.math.byu.edu/~schow/work/IEEEFloatingPoint.htm And, I also provide the answer: precision for interger numbers is in the [+/-1.40239846e-45 .. +/-3.40282347e+38] range.
And a small program to show it:
BEGIN A=3.4028*10^38 PRINT A END
Cheers, aldweb |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 2 -------- 24/11/2005 @ 16:40 by Richard
visitor |
The reason I was asking was that as I was going through the development cycle .. Piaf, iziBasic compile and run through iziBasic -- I would get an error that would require a reset, the reset button in hte message didn't work, so I'd have to press the reset on the back of the T3. I didn't capture the message -- so I can't tell you any more.
The other question was related to the program appearing to hang up when I put in *LARGE* numbers. The routine I'm using to determine prime is to do a MOD of the number, N, with 2 through N-1. If MOD returns 0 -- then the number is not prime. I've tried numbers around 6500 and the routine works fine. Maybe I should look for another approach for determing prime.
This is very fun .. I've been looking for a programming language that is easy to use for the Palm.
Thanks again,
Richard |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 3 -------- 24/11/2005 @ 23:03 by Richard
visitor |
As a follow up...
The error message that I get from time to time is
Fatal Falult, MemoryMgr.c, Line:3757, Invalid chunk ptr, reset (sometimes the reset button works and sometimes it doesn't).
I did a little reading about checking for prime numbers. It is safe to test from 2 to the square root of the N -- rather than from 2 to N-1. This is a big improvement in speed.
Thanks,
Richard |
|
|
Warning: A non-numeric value encountered in /web5/aldweb/www/aldweb_com/www/thread.php on line 497
Answer n° 4 -------- 24/11/2005 @ 23:09 by aldweb
visitor |
Richard,
The error must be in your _ISPRIME routine, because the above source code runs fine (as expected!).
I know very well prime numbers routine too and I even used it here on my web site to benchmark the different development tools for Palm And I also provide the source code for iziBasic (but you got it in the Bench2 sample source code shipped within the ZIP package).
Cheers, aldweb
@+ aldweb |
|
|
topic active
topic closed
Sticky
New message -
Correct message
Close topic
Make sticky
|
|
|
|
|
|