Fóruns: 公開討議 (Thread #26751)

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

PRINT count; "primes below 1000000 found"
PRINT "Now summing up..."
PRINT


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


END
--- snip ---

Responder a #51768×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

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.

Responder a #51768

Responder a #51770×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

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?

Regards,
Responder a #51770

Responder a #51798×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

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.
Responder a #51768

Responder a #51802×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Compiled program does not run (2010-07-07 08:44 by SHIRAISHI Kazuo #51804)

The evaluation precisions of the fundamental four operations is 56 bits for Decimal BASIC binary mode, but may perhaps be 64bits for BASICAcc.
Responder a #51802

Responder a #51804×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Compiled program does not run (2010-07-07 08:56 by SHIRAISHI Kazuo #51806)

BASICAcc does not response while executing, it happens to seem to hang up.
Responder a #51804

Responder a #51806×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login

RE: Compiled program does not run (2010-07-09 06:07 by ukimiku #51845)

Thank you very much for explaining these details. I now know how to handle the most important differences, I think.
Responder a #51806

Responder a #51845×

You can not use Wiki syntax
You are not logged in. To discriminate your posts from the rest, you need to pick a nickname. (The uniqueness of nickname is not reserved. It is possible that someone else could use the exactly same nickname. If you want assurance of your identity, you are recommended to login before posting.) Login