NO

Recent Posts

Pages: [1] 2 3 ... 10
1
User contributions / Re: Big integer arithmetic library
« Last post by TimoVJL on Today at 09:09:44 AM »
pbint.def
Code: [Select]
LIBRARY pbint.dll
EXPORTS
pbkInitBint
pbkReallocBint
pbkFreeBint
pbkCreateBint
pbkDeleteBint
pbkMoveBint
pbkCopyBint
pbkIbToBint
pbkBintToIb
pbkCompareBint
pbkAddBint
pbkSubtractBint
pbkLeftShiftBint
pbkRightShiftBint
pbkMultiplyBint
pbkDivideBint
pbkInitBnum
pbkReallocBnum
pbkFreeBnum
pbkCreateBnum
pbkDeleteBnum
pbkMoveBnum
pbkIbToBnum
pbkDecimalSzToBnum
pbkPrintBnum
pbkBintToDecimalBnum
pbkDecimalBnumToBint
pbmBintPower
pbmUbFactorial
pbmBintSquareRoot
pbmBintGreatestCommonDivisor
pbxLoadBint
pbxSaveBint
2
User contributions / Re: Big integer arithmetic library
« Last post by WiiLF23 on Today at 03:33:01 AM »
Nice work! Very appreciated.

Cheers!
3
User contributions / Re: Big integer arithmetic library
« Last post by frankie on May 20, 2024, 10:58:59 PM »
 :)
4
User contributions / Big integer arithmetic library
« Last post by cosh on May 20, 2024, 07:14:08 PM »
 :) Hi, there
I wrote a library for big integer arithmetic here: https://github.com/coshcage/pbint
It's called pbint means portable big integer library.
The difference between pbint and gnu gmp is that you don't need to control memory manually in pbint, pbint combined heap memory management functions to arithmetic functions together. pbint is smaller and faster. If you are interested in high precision calculation and large integer arithmetic, pbint is suitable for you.

I also tested and compiled pbint with Pelles C compiler. Before compiling pbint with Pelles C you need to alter pbint according to the following instructions:
Delete line 568 register qualifier in pbk.c.
Delete line 621 register qualifier in pbk.c. But don't delete variable declaration clause.

Testing shows to calculate factorial 2000 on an Intel Core i9 9 Gen microprocessor only needs 0.01 seconds.
Here's the code that I used for testing:
Code: [Select]
#include <stdio.h>
#include <Windows.h>
#include "pbk.h"
#include "pbm.h"

int main()
{
P_BINT pc;
P_BNUM p;
LARGE_INTEGER la, lb, lc;


pc = pbkCreateBint(0);
p = pbkCreateBnum(10);

QueryPerformanceFrequency(&lc);
QueryPerformanceCounter(&la);

pbmUbFactorial(pc, 2000); // 2000!

QueryPerformanceCounter(&lb);
printf("%lf\n", (double)(lb.QuadPart - la.QuadPart) / (double)lc.QuadPart);

pbkBintToDecimalBnum(p, pc);

pbkPrintBnum(p);

return 0;
}

Kind regards,
Cosh.
5
Tips & tricks / KAST macro by MrBcx
« Last post by Vortex on May 18, 2024, 09:28:17 PM »
A nice macro by MrBcx used in the BCX language.

Traditional type casting :

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

int main(void)
{
HMODULE hMod;
PIMAGE_NT_HEADERS pNThdr;
PIMAGE_EXPORT_DIRECTORY pDesc;
DWORD NumbOfNames,i;
DWORD* AddrOfNames;

hMod=LoadLibrary("kernel32.dll");

pNThdr=(PIMAGE_NT_HEADERS)((LPBYTE)hMod + ((PIMAGE_DOS_HEADER)hMod)->e_lfanew);

pDesc=(PIMAGE_EXPORT_DIRECTORY)((LPBYTE)hMod + pNThdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);

NumbOfNames =  pDesc -> NumberOfNames;

AddrOfNames = (DWORD *)((LPBYTE)hMod + pDesc -> AddressOfNames);

for(i=0;i<NumbOfNames;i++)
{
printf("%s\n",(*AddrOfNames+(LPBYTE)hMod));

AddrOfNames=AddrOfNames+1;
}

FreeLibrary(hMod);
return 0;
}

The KAST macro for type casting :

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

/* KAST macro by MrBcx */

#define KAST(to_type,old_obj) ((to_type)(old_obj))

int main(void)
{
HMODULE hMod;
PIMAGE_NT_HEADERS pNThdr;
PIMAGE_EXPORT_DIRECTORY pDesc;
DWORD NumbOfNames,i;
DWORD* AddrOfNames;

hMod=LoadLibrary("kernel32.dll");

pNThdr=KAST(PIMAGE_NT_HEADERS,KAST(LPBYTE,hMod) + KAST(PIMAGE_DOS_HEADER,hMod)->e_lfanew);

pDesc=KAST(PIMAGE_EXPORT_DIRECTORY,KAST(LPBYTE,hMod) + pNThdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);

NumbOfNames =  pDesc -> NumberOfNames;

AddrOfNames = KAST(DWORD *,KAST(LPBYTE,hMod) + pDesc -> AddressOfNames);

for(i=0;i<NumbOfNames;i++)
{
printf("%s\n",*AddrOfNames+KAST(LPBYTE,hMod));

AddrOfNames=AddrOfNames+1;
}

FreeLibrary(hMod);
return 0;
}
6
Expert questions / Re: TikToken
« Last post by HellOfMice on May 18, 2024, 01:21:19 PM »
I have used the web interface and created a database with more than 174 000 english words and their tokens.
Thank you everybody for your help

7
Expert questions / Re: TikToken
« Last post by John Z on May 18, 2024, 10:45:25 AM »
For OpenAI a token is a group of three or four characters. The solution I have made is to divide the length of each word by three and add 1 word length is greather than three.


OpenAI tokenizer https://platform.openai.com/tokenizer

One of the methods to get better performance (at least using English language) is to look for both common prefixes and common suffixes and break the word there initially.  This creates more efficient tokens as I understand that.

To that end the following link might be useful for the most common of each - 

https://www.scholastic.com/content/dam/teachers/lesson-plans/migrated-files-in-body/prefixes_suffixes.pdf

John Z
8
Work in progress / Re: zlib 1.2.8 source converted for __stdcall
« Last post by John Z on May 17, 2024, 09:53:49 PM »
zlib 1.2.8 source converted for __stdcall.

Thanks Timo!

John Z
9
Work in progress / Re: zlib 1.2.8 source converted for __stdcall
« Last post by WiiLF23 on May 16, 2024, 10:22:27 PM »
Keep in mind, zlib1 (note the 1 at the end of the filename) is a mainstream effort from the authors to maintain a corrected compilation of the library, and its codebase in the wild. The documentation explains this very throughly, as well as the mistake that was overlooked prior to the mass release of zlib (without the 1) at the original release date. The naming convention is important. What you name the file after doesn’t mean much, as long as it is a corrected build (away from regular zlib.xx).

People need to know this, who are aware of the libs history.

So, I recommend you indicate this as to clarify it is the corrected code.
10
Windows questions / Re: WIN32 ComboBox control
« Last post by WiiLF23 on May 16, 2024, 10:09:53 PM »
The combobox control has a buggy history, and often developers will attempt to alter the controls appearance but will find that the win32 shell team implemented a group of pixels to draw the glyph, but it is all tied together so you have to either draw it all yourself or leave it alone in respect to its default style.

There are also undocumented API messages, which stump many. Not my favourite control to work with, and often I just use a Edit control and I draw a non-client area region and paint my own dropdown with highlight events (WM_PAINT, WM_MOUSEMOVE) with a Hittest on the rects region, and I go from there in respect to the label items.

I probably won’t ever use a traditional combobox anytime soon lol
Pages: [1] 2 3 ... 10