NO

Recent Posts

Pages: [1] 2 3 ... 10
1
Beginner questions / Re: AI, Google Search, and Internet Changes
« Last post by John Z on Today at 03:35:20 PM »
hello thomasmuller,

Welcome to the forum with your first post.

You mention "our programming practices and learning experiences with Pelles C", have you actually used it?

Are you a reporter or other type of writer? 

What will be done with this information?

Will responders be quoted ? 

I think you should introduce yourself so others may be more comfortable in responding and knowing the purpose, or use case for the replies... IMO of course....

John Z
 
2
Beginner questions / AI, Google Search, and Internet Changes
« Last post by thomasmuller on Today at 10:37:44 AM »
Hi everyone,
With the advancements in AI and continuous changes to Google Search, I'm curious about how these developments are influencing our programming practices and learning experiences with Pelles C.
- AI Tools: Have you started using AI tools to assist in coding or debugging? How effective are they?
- Search Algorithm Updates: Do the recent Google Search changes make it easier or harder to find specific programming resources?
- Future Impact: How do you think these technological advancements will shape the future of learning and using Pelles C?
Looking forward to your insights!
3
Bug reports / Re: WIN7: InitializeContext KERNEL32.DLL error
« Last post by TimoVJL on Today at 09:40:55 AM »
Just for fun:
WIN7: InitializeContext KERNEL32.DLL error
So you can get that error with Windows 7 SP1 too  ;)
4
Bug reports / Re: WIN7: InitializeContext KERNEL32.DLL error
« Last post by Vortex on Yesterday at 10:07:25 PM »
Another version :

Code: [Select]
#include <stdio.h>
#include <windows.h>

int main(int argc, char *argv[])
{

char *report[] = {"%s is exporting %s","%s does not export the function %s"};

HMODULE hDll;
FARPROC func;
int rv;

if (argc!=3){
printf("Usage : VerifyExport DLLname FuncName\n");
return 2;
}

hDll=LoadLibrary(argv[1]);

if (!hDll) {
printf("%s could not be loaded.",argv[1]);
return 3;
}

func=GetProcAddress(hDll,argv[2]);

rv=!func;

printf(report[rv],argv[1],argv[2]);

FreeLibrary(hDll);

return rv;
}
5
User contributions / Re: Big integer arithmetic library
« Last post by TimoVJL on May 26, 2024, 12:03:30 PM »
to make def file from map file, copy relevant part of it and use a tiny helper program like this:
Code: [Select]
#include <stdio.h>

int __cdecl main(void)
{
FILE *fi = NULL;
char s[100];
if (fi = fopen("pbint.lst", "r")) {
while (fgets(s, 100, fi)) {
char *p = s+21;
while (*p != ' ') p++;
*p++ = 10;
*p = 0;
printf(s+21);
}
fclose(fi);
}
return 0;
}
6
User contributions / Re: Big integer arithmetic library
« Last post by cosh on May 24, 2024, 10:21:16 PM »
Hi, fellows
I finished a big integer calculator.
You guys may download it here: https://github.com/coshcage/pbint/blob/main/Samples/05-24-24_13-09.c
The calculator supports +-*/^(power) and brackets.
I also paste this code here:
Code: [Select]
#include <stdio.h>
#include <string.h>
#include "pbm.h"
#define MAXLEN 100

P_BINT CatchFirstNumber();
P_BINT CalcBrackets();
P_BINT CalcAdditional();
P_BINT CalcAdvanced();
P_BINT CalcPrimary();

char * expr;

P_BINT CalcPrimary()
{
P_BINT x, y = NULL, r;
int c;
r = pbkCreateBint(0);
x = CalcAdvanced(expr);
c = expr[0];
while ('+' == c || '-' == c)
{
++expr;
y = CalcAdvanced(expr);
if ('+' == c)
{
pbkAddBint(r, x, y);
pbkMoveBint(x, r);
}
else if ('-' == c)
{
pbkSubtractBint(r, x, y);
pbkMoveBint(x, r);
}
c = expr[0];
}
if (expr[0] == ')')
++expr;
pbkDeleteBint(r);
if (NULL != y)
pbkDeleteBint(y);
return x;
}

P_BINT CalcAdvanced()
{
P_BINT x, y = NULL, r, k;
int c;
r = pbkCreateBint(0);
k = pbkCreateBint(0);
x = CalcAdditional(expr);
c = expr[0];
while ('*' == c || '/' == c)
{
++expr;
y = CalcAdvanced(expr);
if ('*' == c)
{
pbkMultiplyBint(r, x, y);
pbkMoveBint(x, r);
}
else if (c == '/')
{
pbkDivideBint(r, k, x, y);
pbkMoveBint(x, r);
}
c = expr[0];
}
pbkDeleteBint(r);
pbkDeleteBint(k);
if (NULL != y)
pbkDeleteBint(y);
return x;
}

P_BINT CalcAdditional()
{
P_BINT x, y, r;
r = pbkCreateBint(0);
x = CalcBrackets(expr);
if ('^' == expr[0])
{
_ub n;
++expr;
y = CalcAdditional(expr);
n = GETABS(pbkBintToIb(y));
pbmBintPower(r, x, n);
pbkDeleteBint(y);
pbkDeleteBint(x);
return r;
}
return x;
}

P_BINT CalcBrackets()
{
if ('(' == expr[0])
{
++expr;
return CalcPrimary(expr);
}
else
{
return CatchFirstNumber(expr);
}
}

P_BINT CatchFirstNumber()
{
size_t i;
P_BINT r;
P_BNUM t;
char szT[2] = { 0 };
char szTar[MAXLEN] = { 0 };
r = pbkCreateBint(0);
t = pbkCreateBnum(10);
for (i = 0; expr[0] != 0 && i < MAXLEN; ++expr, ++i)
{
if (expr[0] >= '0' && expr[0] <= '9')
{
szT[0] = expr[0];
strcat(szTar, szT);
}
else
{
pbkDecimalSzToBnum(t, szTar);
pbkDecimalBnumToBint(r, t);
pbkDeleteBnum(t);
return r;
}
}
pbkDecimalSzToBnum(t, szTar);
pbkDecimalBnumToBint(r, t);
pbkDeleteBnum(t);
return r;
}

int main(int argc, char ** argv)
{
char szExpr[MAXLEN] = { 0 };
while (EOF != scanf("%s", szExpr))
{
P_BINT r;
P_BNUM t;
expr = szExpr;
t = pbkCreateBnum(10);
r = CalcPrimary();
pbkBintToDecimalBnum(t, r);
printf("= ");
pbkPrintBnum(t);
pbkDeleteBnum(t);
pbkDeleteBint(r);
printf("\n");
}
}

Does anyone want to develop this library with me together?
7
User contributions / Re: Big integer arithmetic library
« Last post by cosh on May 24, 2024, 08:15:53 PM »
hello cosh
if you implement a multiply BigInt by 32-bit integer then your factorial would be about 3 times faster

And this is the code to do factorial:
Code: [Select]
_boolean pbmUbFactorial(P_BINT r, _ub n)
{
BINT R = { 0 }, N = { 0 };

pbkInitBint(&R, 0);
pbkInitBint(&N, 0);

SETFLAG(r, 1);
r->data[0] = 1;

SETFLAG(&N, 1);

while (n - 1)
{
if (!pbkMoveBint(&R, r))
{
pbkFreeBint(&R);
pbkFreeBint(&N);
return FALSE;
}
N.data[0] = n; // Please notice here, it is directly insert a 32-bit integer to bigint.
if (!pbkMultiplyBint(r, &N, &R))
{
pbkFreeBint(&R);
pbkFreeBint(&N);
return FALSE;
}
--n;
}

pbkFreeBint(&R);
pbkFreeBint(&N);
return TRUE;
}
8
User contributions / Re: In-memory relational database
« Last post by cosh on May 24, 2024, 08:01:44 PM »
Now svimrdb is dedicated to a high-performance in-memory database.
Compare to sqlite in-memory database svimrdb runs 6 times faster than sqlite.
Here are the codes that I used to test them:
Code: [Select]
#include <stdio.h>

#include "sqlite3.h"


int main() {

    sqlite3 * db;

    char * errMsg = 0;

    int rc;

    //rc = sqlite3_open("test.db", &db);
    rc = sqlite3_open(":memory:", &db);

    if (rc) {

        fprintf(stderr, "%s\n", sqlite3_errmsg(db));

        return 1;

    }

    char * sql = "CREATE TABLE IF NOT EXISTS data (id INTEGER PRIMARY KEY)";

    rc = sqlite3_exec(db, sql, 0, 0, &errMsg);

    if (rc != SQLITE_OK) {

        fprintf(stderr, "%s\n", errMsg);

        sqlite3_free(errMsg);

        return 2;

    }

    sqlite3_exec(db, "BEGIN TRANSACTION", 0, 0, 0);



    for (int i = 1; i <= 10000; i++) {

        char insertSql[100];

        sprintf(insertSql, "INSERT INTO data (id) VALUES (%d)", i);

        rc = sqlite3_exec(db, insertSql, 0, 0, &errMsg);

        if (rc != SQLITE_OK) {

            fprintf(stderr, "%s\n", errMsg);

            sqlite3_free(errMsg);

            sqlite3_exec(db, "ROLLBACK", 0, 0, 0);

            return 3;

        }

    }



    sqlite3_exec(db, "COMMIT", 0, 0, 0);


    sqlite3_close(db);



    printf("done!\n");



    return 0;

}
Code: [Select]
#include "svimrdb.h"
#include <stdio.h>

int main()
{
int i, * p = &i;
P_TRANS ptrans;
P_TABLE ptbl;
P_ARRAY_Z parrhdr;
P_ARRAY_Z parrg;

parrg = strCreateArrayZ(1, sizeof(void *));

parrhdr = strCreateArrayZ(1, sizeof(TBLHDR));
((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->ct = CT_INTEGER;
((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->phsh = NULL;
((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->cr = CR_PRIMARY_KEY;
((TBLHDR *)strLocateItemArrayZ(parrhdr, sizeof(TBLHDR), 0))->strname = "number";

strInsertItemArrayZ(parrg, &p, sizeof(void *), 0);

ptrans = siBeginTransaction();

ptbl = siCreateTable(ptrans, "Student", parrhdr);

while (TRUE != siTrylock(ptrans, ptbl, LT_S)) // Share lock.
;

while (TRUE != siTrylock(ptrans, ptbl, LT_X)) // Write lock.
;

for (i = 0; i < 10000; ++i)
{
if (TRUE != siInsertIntoTableBase(ptrans, ptbl, NULL, parrg))
{
printf("%s, %d\n", "failed!", i);
siRollbackTransaction(NULL, ptrans);
siReleaseAllTransaction();
return 1;
}
}

siCommitTransaction(ptrans);

siDeleteTable(NULL, ptbl);

siReleaseAllTransaction();

strDeleteArrayZ(parrg);

strDeleteArrayZ(parrhdr);

return 0;
}
svimrdb:
real    0m0.018s
user    0m0.004s
sys     0m0.000s
sqlite:
done!

real    0m0.064s
user    0m0.031s
sys     0m0.000s
 8)
9
User contributions / Re: Big integer arithmetic library
« Last post by cosh on May 24, 2024, 02:55:05 PM »
cosh
I think that you misunderstood me about "multiply BigInt by 32-bit integer", anyway, here's a very simple factorial function to illustrate my point

Hello, jack
It's my mistake. I misunderstood you. However, I think multiply BigInt by 32-bit integer won't accelerate this(pbint) algorithm's speed. Cuz, theoretically, pbkMultiplyBint needs two operations: 1st is add, 2nd is left shift. For this method, the complexity of multiplying by a bigint is similar to multiplying by a 32-bit int. I tested your package(Thank you for providing it.), And 2000! by using pbkMultiplyBint only needs 0.001s but converting from base 2 Bint to base 10 Bnum needs more time. Your package performs also well, that is 0.002s.

Thank you for your reply, jack.
John C. Cage.
10
User contributions / Re: Big integer arithmetic library
« Last post by jack on May 23, 2024, 04:35:19 PM »
cosh
I think that you misunderstood me about "multiply BigInt by 32-bit integer", anyway, here's a very simple factorial function to illustrate my point
Pages: [1] 2 3 ... 10