Recent

Author Topic: Anyone interested in testing a new Big Integer library?  (Read 19620 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2398
    • UVviewsoft
Re: Anyone interested in testing a new Big Integer library?
« Reply #30 on: November 23, 2023, 09:32:41 am »
If you did not notice: I wrote few 'issues' to the Github.

dbannon

  • Hero Member
  • *****
  • Posts: 2788
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Anyone interested in testing a new Big Integer library?
« Reply #31 on: November 23, 2023, 11:58:35 am »
I looked at the link, but couldn't find anything that resembled "Clear BSD License".
https://choosealicense.com/licenses/bsd-3-clause-clear/

However, sounds like the "zero clause" one may suit you, its the everything goes one. https://opensource.org/license/0bsd/ - 10 or so lines of text and its will not worry you again.

Yep, I agree, the wasted time is a pain in the thing you sit on. We should have never let the lawyers see what fun we were having .....

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #32 on: November 24, 2023, 05:17:04 pm »
If you did not notice: I wrote few 'issues' to the Github.
Thanks for your suggestions. Can I discuss them with you here?
I accepted and implemented 3 of your suggestions.
However, there are two that I am not going to implement... Indentation and Name Casing.
I have problems reading code where the indentation that is too narrow; just 2 spaces is not enough for me and makes the code difficult for me to read.
However, if you go into Lazarus->Tools-Options->Editor->General->Tab-and-Indent, then untick tabs-to-space and set tab-width=2, I think that will give you the view that you prefer.
I have similar problems reading traditional name casing...
I find it very difficult to read & spellcheck a name like "TMultiLeadingZeros", whereas "T_Multi_Leading_Zeros" I find much easier.
These two issues are to do with source code style and do not affect the functionality/usability of the library by others.  I think you will agree that, as the author of the library, it is important that I am able to easily read and debug the code.

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #33 on: November 25, 2023, 10:59:29 am »
I have just made version 4.25 available.
If anyone has downloaded a previous version, please upgrade to this one. It has important bug fixes, and other improvements.

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #34 on: November 25, 2023, 01:01:43 pm »
Has anyone used my library code?
I would be especially interested to know if anyone has plugged it into existing code which is highly object-oriented, and how difficult it was.
I don't write much object-oriented code myself, so I don't know easy it would be to plug the library into an existing program using that type of code.
Thanks.

bytebites

  • Hero Member
  • *****
  • Posts: 639
Re: Anyone interested in testing a new Big Integer library?
« Reply #35 on: November 25, 2023, 01:32:18 pm »
Unit UBool is missing?

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #36 on: November 25, 2023, 04:16:15 pm »
Unit UBool is missing?
Fixed.
Sorry about that. I only recently separated the UBool type into its own unit file, and forgot to upload it.

bytebites

  • Hero Member
  • *****
  • Posts: 639
Re: Anyone interested in testing a new Big Integer library?
« Reply #37 on: November 26, 2023, 08:31:45 am »
{$ifdef 32bit} is always true

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #38 on: November 26, 2023, 11:50:15 am »
{$ifdef 32bit} is always true
I can't see the problem.
Near the top of the unit code, there is a line "{$define 64bit}". If you are in a 32bit environment, you should change this to "{$define 32bit}". The code has "{$define 64bit}", and from a test I've done just now, it looks to me like the correct 64bit code is being used, and the 32bit code is not.
Can you explain the problem you are seeing in more detail please?
Thanks.

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Anyone interested in testing a new Big Integer library?
« Reply #39 on: November 26, 2023, 11:52:55 am »
{$ifdef 32bit} is always true
I can't see the problem.
Near the top of the unit code, there is a line "{$define 64bit}". If you are in a 32bit environment, you should change this to "{$define 32bit}". The code has "{$define 64bit}", and from a test I've done just now, it looks to me like the correct 64bit code is being used, and the 32bit code is not.
Can you explain the problem you are seeing in more detail please?
Thanks.
Maybe is expected that the 64 bit code is used by default in 64 bit builds?

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #40 on: November 26, 2023, 12:42:07 pm »
Maybe is expected that the 64 bit code is used by default in 64 bit builds?
Ideally, I would like to make the 64bit vs 32bit setting automatic, by having the code detect it. But I could not see a way of doing that. Suggestions are welcome here.
However, my understanding is that the compiler provides 64bit integers, even on a 32bit CPU, and I wanted to give the programmer the option to override that, and force 32bit integers internally. Some CPUs have differences in the way 32bit vs 64bit registers work, especially when they overflow and on bit shift operations.
When coding my library, I wanted to create a 64bit Pascal translation of Henry Warren's C implementation of Knuth's fast division algorithm, but could not get it to work.
One of the problems I encountered was that the behaviour of 64bit registers was different to 32bit registers when they overflowed. Henry Warren's C code was designed for 32bit registers, and the C code seems to allow registers to overflow, and then depends on that behaviour of the register. When I stepped through my Pascal translation, the register behaviour assumed by the Warrens's C code seemed different to the behaviour I was seeing. Another factor might have been the code that Free Pascal was generating might have had differences.
Because of these problems, I wanted to give the programmer using my library the option of forcing 32bit integers.
« Last Edit: November 26, 2023, 12:59:09 pm by ad1mt »

lainz

  • Hero Member
  • *****
  • Posts: 4468
    • https://lainz.github.io/
Re: Anyone interested in testing a new Big Integer library?
« Reply #41 on: November 26, 2023, 12:54:47 pm »
Maybe is expected that the 64 bit code is used by default in 64 bit builds?
Ideally, I would like to make the 64bit vs 32bit setting automatic, by having the code detect it.But I could not see a way of going that. Suggestions are welcome here.
However, my understanding is that the compiler provides 64bit integers, even on a 32bit CPU, and I wanted to give the programmer the option to override that, and force 32bit integers internally. Some CPUs have differences in the way 32bit vs 64bit registers work, especially when they overflow.

You can use this with FPC:

Code: Pascal  [Select][+][-]
  1. {$IFDEF CPU64}
  2.   {$define 64bit}
  3. {$ELSE}
  4.   {$define 32bit}
  5. {$ENDIF}

Put that code on top, anyways the user can comment that and override the defines as needed.
« Last Edit: November 26, 2023, 12:56:20 pm by lainz »

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #42 on: November 26, 2023, 01:05:17 pm »

You can use this with FPC:

Code: Pascal  [Select][+][-]
  1. {$IFDEF CPU64}
  2.   {$define 64bit}
  3. {$ELSE}
  4.   {$define 32bit}
  5. {$ENDIF}

Put that code on top, anyways the user can comment that and override the defines as needed.
That's a good suggestion. Thanks.
And if I had RTFM properly, I would have spotted it myself   :D
I am now wondering if I need to code a 16bit option!   :o

bytebites

  • Hero Member
  • *****
  • Posts: 639
Re: Anyone interested in testing a new Big Integer library?
« Reply #43 on: November 26, 2023, 04:07:24 pm »
{$ifdef 32bit} is always true. It appears that this is IDE-error. IDE does not gray out code, when the name starts with number.
Contrast to Delphi documentation says that 32bit is not valid name.

ad1mt

  • Full Member
  • ***
  • Posts: 199
    • Mark Taylor's Home Page
Re: Anyone interested in testing a new Big Integer library?
« Reply #44 on: November 28, 2023, 05:13:30 pm »
I've just made version 4.27 available. This has an optimisation in the divide algorithm, taken from Knuth/Warren, which gives a big increase in speed.

 

TinyPortal © 2005-2018