Compiled program does not run (2010-07-06 03:45 by ukimiku #51768)
Dear Mr.
The following program code (looking for the prime below 1000000 that can be written as the sum of the most primes) runs fine in the interpreter of DECIMAL BASIC (7.4.6), but does not do anything in the compiled version. Maybe you would like to look into this? I have no ideas as to where the problem may be since the program does not display anything.
Thank you.
Regards.
--- snip ---
LET n_primes = 1000000
DIM primes(n_primes)
LET primes$=REPEAT$("p", n_primes)
LET primes$(1:1) = "-"
LET n = 2
LET count = 0
DO
LET count = count + 1
LET primes(count) = n
LET primes$(n:n) = "p"
FOR i = n + n TO n_primes STEP n
LET primes$(i:i) = "-"
NEXT i
LET found = 0
FOR i = n+1 TO n_primes
IF primes$(i:i) = "p" THEN
LET n = i
LET found = 1
EXIT FOR
END IF
NEXT i
LOOP UNTIL found = 0
REM finding the prime below 1000000 expressable as the sum of most consecutive primes
LET pcount_max = 0
LET p_max = 0
FOR pn = 2 TO count
LET p = primes(pn)
FOR index = 1 TO pn - 1
LET sum = 0
LET i = index - 1
DO WHILE sum < p
LET i = i + 1
LET sum = sum + primes(i)
LOOP
IF sum = p THEN
LET primes_used = i - index + 1
IF primes_used > pcount_max THEN
LET pcount_max = primes_used
LET p_max = p
PRINT p; "written as sum of"; primes_used; "primes."
EXIT FOR
END IF
END IF
NEXT index
NEXT pn
RE: Compiled program does not run (2010-07-06 08:45 by SHIRAISHI Kazuo #51770)
The program will probably run, but it may take tremendous hours, becuase the character set is UTF-8.
You can change the character set to BYTE selecting "Character set" "Byte" on the "behavior" tab in the Option-Compatibility menu.
You can also add a statement
OPTION CHARACTER BYTE
at the first of the program.
RE: Compiled program does not run (2010-07-07 02:23 by ukimiku #51798)
Thanks. So do I understand correctly that the interpreter does not assume UTF-8 but the compiler does? Are there more such differences I should be aware of?
RE: Compiled program does not run (2010-07-07 07:25 by SHIRAISHI Kazuo #51802)
Decimal BASIC has the similar option of character set.
Decimal BASIC Japanese version assumes UTF-8 but English version does not.
BASICAcc has no distinction of Japanese edition or English edition, so the option of character set is set to the safe side.
BASICAcc and Decimal BASIC are both in accordance with the Full BASIC standard, and have many incompatibility with the standard in common, but BASICAcc and Decimal BASIC are not completely identical in their behavior. For example, their binary numerical operations may have slight differences.