Big numbers, strange errors

May 20, 2008
11,400
99
Syracuse, NY, USA
I have a @FACT plugin (factorial), essentially:
Code:
{
   ...
   Evaluate(psz);
   INT x = _wtoi(psz);
   while ( x > 1 )
   {
     Sprintf(psz+lstrlen(psz), L"*%d", (x -= 1));
     Evaluate(psz);
   }
   return 0;
}
It works fine up to %@FACT[3248] when he result (and Evaluate()'s argument) are just under 10000 characters (@eval's output limit for integers). So I limit @FACT to numbers <= 3248. That works fine.

I'm working on another plugin, @BINOM[n,k] (binomial coefficient, n!/(k!(n-k)!)). Right now,
Code:
INT WINAPI f_BINOM ( WCHAR *psz )
{
   DWORD n, k;
   if ( Sscanf(psz, L"%u,%u", &n, &k) != 2 || n > 3248 || k > n )
     return 0;
   Sprintf(psz, L"%%@FACT[%d] / %%@FACT[%d] / %%@FACT[%d]", n, k, n-k);
   ExpandVariables(psz, 0);
   Evaluate(psz);
   return 0;
}

If I try @BINOM[3200,1600] (about 1000 digits), it works. The expanded line passed to Evaluate() is about 18700 characters long and its first (and longest) token is about 9830 characters long. If I try it a second time, any of a variety of things may happen. One result (which I've never seen before) is:
Code:
v:\> echo %@binom[3200,1600]
MAPM Error: 'm_apm_to_fixpt_string', Out of memory
After that, a third try produces nothing
Code:
v:\> echo %@binom[3200,1600]
v:\>
And ~30 seconds later, TCC disappears.

I don't think I'm running into TCC's size limits. But I'd like to limit it to avoid errors.
Does anyone (Rex?) have an idea of what difficulty it's running into?
 
Similar threads
Thread starter Title Forum Replies Date
Alpengreis Fixed Crash after copy dialog with big TCC.exception.log Support 5
B Asking for a big favor Support 4
M Little bug, big consequences .. Support 6
rconn Big storms, no electricity at JP Software Support 6
vefatica Big collection of MSI files Support 3
R Big Problem Please Help Support 2
D Fixed @VERSION does not increment pre-fixed version numbers. Support 1
dcantor How to make line numbers fixed width in FFIND Support 11
dcantor Arithmetic errors in large numbers Support 12
R strange bug? Support 7
Jesse Heines Strange Line Wrapping Behavior Support 14
F strange results Support 9
M Strange error messages from TCC in FTP copy Support 7
M Another possibly strange remote registry issue Support 5
forbin Strange handling of [nonbright] magenta background (v22) Support 2
N Fixed Strange dir behavior Support 6
vefatica REGDIR, strange error message Support 7
T WAD Strange Unexpected "features" in the Debugger Support 2
P Strange mouse behavior with list Support 2
vefatica Strange tcc.exception.log Support 7
vefatica A strange one Support 0
D Strange DO behavior with /O Support 5
Glenn Bowes Strange text at startup Support 5
Steve Pitts WAD Strange output from DEL of a non-existent directory Support 7
aedthuio Strange... lpksetup Support 4
CWBillow dir /4 strange Support 2
D Strange issue with FOR loop Support 15
MikeBaas Strange prob with %@replace.. Support 4
vefatica OT: strange files in %TEMP Support 10
Dan Glynhampton Documentation v15 help: Strange links in @INT topic Support 0
R WAD Strange output from "memory" command Support 1
M Yet another strange something re something called "@TCONVERT" Support 8
Roedy How to? Strange colours Support 9
M WAD Strange "Start" misbehavior... Support 10
vefatica Very strange console font corruption Support 3
Steve Pitts Strange problem with FREE Support 10
A strange error in alias Support 9
newgeekorder Debugger IDE - strange tab and parameter behaviour Support 1
Exolon Strange Prompt. Support 6
vefatica Strange folders Support 1
T Strange CPU value Support 3
J Strange error: unset /s Support 14
M Strange behavior... Support 2
CWBillow Strange happenings Support 2
B Strange handling of a .BAT file Support 5
vefatica Strange behavior reloading SHRALIAS sav files. Support 1
J ASSOC / FTYPE strange error message Support 3
D Strange crashes in @CRC32 and @MD5 Support 9
Charles Dye Strange output, here-doc redirection, TYPE, //UnicodeOutput=Yes Support 6
S Strange CHKDSK behavior Support 6

Similar threads