Lazarus

Free Pascal => FPC development => Topic started by: Чебурашка on May 25, 2022, 01:44:40 pm

Title: DateUtils.Inc* with double instead on Int64
Post by: Чебурашка on May 25, 2022, 01:44:40 pm
Hi,
I was using the DateUtils.IncSeconds(time, seconds) function, but my seconds parameter ended up being a floating point value.
I remembered that these function want a Int64 number, so I had to use milliseconds with a little rounding.

Would it be senseful to extend them to floating point inputs instead of interger?
All in all the inner calculation does

Code: Pascal  [Select][+][-]
  1. Function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime;
  2. begin
  3.   if AValue>=0 then
  4.     Result:=AValue+ANumberOfSeconds/SecsPerDay
  5.   else
  6.     Result:=IncNegativeTime(Avalue,ANumberOfSeconds/SecsPerDay);
  7.   MaybeSkipTimeWarp(AValue,Result);
  8. end;
  9.  

and this would work also with ANumberOfSeconds being a floating point.

Of course the same argument applies to all other DateUtils.Inc* functions.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: AlexTP on May 25, 2022, 01:52:15 pm
This must be Delphi compatible,
https://docwiki.embarcadero.com/Libraries/Sydney/en/System.DateUtils.IncSecond
but if overload will appear, maybe its OK.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: Чебурашка on May 25, 2022, 02:00:35 pm
I correct myself:

Quote
The same argument might apply to DateUtils.IncDay, DateUtils.IncHour, DateUtils.IncSecond, DateUtils.IncMilliSecond functions.

Others make less sense to be floating point.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: winni on May 25, 2022, 05:49:22 pm
Hi!

If you know the basics of TDateTime thren you don't need IncSeconds and friends.

Code: Pascal  [Select][+][-]
  1. Type
  2. TDateTime = Double;
  3.  

The Integer part contains the days since 30. December 1899

The fractional part contains the time and is organized this way:

1 hour = 1.0 / 24
1 minute = 1.0 / (24*60)
1 second = 1.0/ (24*60*60)

To increment your DateTime with one second you can do
Code: Pascal  [Select][+][-]
  1. MyDateTime := MyDateTime + 1/ (24*60*60);

To increment your DateTime with 45 days you can do:

Code: Pascal  [Select][+][-]
  1. MyDateTime := MyDateTime +  45;
  2.  

Winni
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: Remy Lebeau on May 25, 2022, 06:08:35 pm
All in all the inner calculation does

Code: Pascal  [Select][+][-]
  1. Function IncSecond(const AValue: TDateTime; const ANumberOfSeconds: Int64): TDateTime;
  2. begin
  3.   if AValue>=0 then
  4.     Result:=AValue+ANumberOfSeconds/SecsPerDay
  5.   else
  6.     Result:=IncNegativeTime(Avalue,ANumberOfSeconds/SecsPerDay);
  7.   MaybeSkipTimeWarp(AValue,Result);
  8. end;
  9.  

Delphi stopped relying on floating-point math in the DateUtils unit over a decade ago, it was causing too many problems (rounding issues, etc).  Now, most of the date/time calculations are performed by first converting TDateTime to TTimeStamp, manipulating the TTimeStamp as needed using integer math, and then converting the result back to TDateTime.  Much more accurate, albeit maybe slightly less efficient.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: wp on May 25, 2022, 06:17:51 pm
If you know the basics of TDateTime thren you don't need IncSeconds and friends.[...]
Your summary is correct. However, this simple calculation results in an "inverted" time when the date is negative. This case is covered correctly by the IncXXX functions:
Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. uses
  4.   SysUtils, DateUtils;
  5.  
  6. var
  7.   t, t0: TDateTime;
  8. begin
  9.   t0 := EncodeTime(9, 0, 0, 0);   // 9:00 (AM). But note that the date part is 0
  10.   WriteLn(FormatDateTime('hh:nn', t0));
  11.  
  12.   // 1 day earlier
  13.   // We're expecting the time to be 9:00 again. But the simple subtraction makes it 15:00 (3:00 PM)
  14.   // This is because the date part is negative now.
  15.   t := t0-1.0;
  16.   WriteLn(FormatDateTime('hh:nn', t));
  17.  
  18.   // Now the same calculation but using the IncDay function -> the result is correct.
  19.   t := IncDay(t0, -1);
  20.   WriteLn(FormatDateTime('hh:nn', t));
  21.  
  22.   ReadLn;
  23. end.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: winni on May 25, 2022, 06:49:40 pm
Hi!

But that is not a special problem of TDateTime:

You  allways run in trouble with negative time and/or date.

The greatest disadvantage of TDateTime is the offset date  30. December 1899.
This means you can use TDateTime for office use but it is impossible to do some historical  research before 1900 with TDateTime.

They should have taken an offset date 1.1.0001  or - even better -  use the scientific Julian Days starting at 1.1. -4712  (4713 BC).

Winni
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: Чебурашка on May 27, 2022, 09:09:19 am
Hi!

If you know the basics of TDateTime thren you don't need IncSeconds and friends.

Code: Pascal  [Select][+][-]
  1. Type
  2. TDateTime = Double;
  3.  

The Integer part contains the days since 30. December 1899

The fractional part contains the time and is organized this way:

1 hour = 1.0 / 24
1 minute = 1.0 / (24*60)
1 second = 1.0/ (24*60*60)

To increment your DateTime with one second you can do
Code: Pascal  [Select][+][-]
  1. MyDateTime := MyDateTime + 1/ (24*60*60);

To increment your DateTime with 45 days you can do:

Code: Pascal  [Select][+][-]
  1. MyDateTime := MyDateTime +  45;
  2.  

Winni

You are right with the direct calculations, I also did so several times.

But lately I migrated to IncXXX because I perceived them comfortable, reader friendly, and able to manage transparently the oddities of the TDateTime calculations.

I was just wondering if was senseful to extend them allowing fractional quantities increment/decrement, like add 2.58 seconds or 7.652 hours.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 07, 2022, 11:58:07 am
There's about 2^62 seconds in the lifespan of the universe. Fits a single Int64. So set 0000-01-01T00:00 to be 0. Universal time.

The main frustration: leap seconds. Although time zones will be as usual.

Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 07, 2022, 02:01:15 pm
Pardon me for jumping in, but can anybody comment on why TDateTime isn't an (80-bit) extended on platforms that support it?

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: PascalDragon on June 07, 2022, 02:10:08 pm
Pardon me for jumping in, but can anybody comment on why TDateTime isn't an (80-bit) extended on platforms that support it?

Because Delphi did so. And the accuracy of Double is probably sufficient for the intended purpose.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: winni on June 07, 2022, 02:40:45 pm
Hi!

TDateTime is a Double since Delphi 1.0

So ask Borland ....

Winni
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 07, 2022, 02:43:44 pm
Because Delphi did so. And the accuracy of Double is probably sufficient for the intended purpose.

Hmm. But we're both  further from the epoch (1900?) than when Borland selected it (late 90s?) and expecting to be able to use smaller intervals for timeouts etc. as computers speed up (assuming, of course, that that trend continues).

Since a TDateTime should be treated as opaque, is binary compatibility that important?

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 07, 2022, 03:15:49 pm
Exact time is a bit more challenging, as you need 144 bits to store the amount of Planck time units for each second. So, if we take 192 bits for that and add the 64 bits for the seconds, we end up with 256 bits and a universe-shattering precision that is never going to be outdated :)

Edit: if you count seconds in Planck time, the value won't be exact, but extremely close. And as you convert from a large integer of Planck time to days and seconds, it doesn't matter.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: winni on June 07, 2022, 03:17:41 pm
Since a TDateTime should be treated as opaque, is binary compatibility that important?

MarkMLl

Hi!

There is so much code around since more than 25 years that relies on the internal structure of TDateTime.
If you change this you break a lot of existing code.

TDateTime is sufficient for Office Apps.
If you got other needs then use another Type of DateTime.

If you make historical  research the use the Julian Days.

If you need milliseconds then use QWords like getTickCount64.

Winni
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 07, 2022, 03:45:22 pm
There is so much code around since more than 25 years that relies on the internal structure of TDateTime.
If you change this you break a lot of existing code.

Are you honestly trying to tell me Winni that people are doing internal bitwise manipulation of TDateTime?

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: marcov on June 07, 2022, 03:46:54 pm
Are you honestly trying to tell me Winni that people are doing internal bitwise manipulation of TDateTime?

No, but floating point math, like +1.0 or even 1/86400 etc is often done with it.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: winni on June 07, 2022, 04:36:46 pm
Are you honestly trying to tell me Winni that people are doing internal bitwise manipulation of TDateTime?

No, but floating point math, like +1.0 or even 1/86400 etc is often done with it.

Bravo Marcov!

Example:

s := "Please pay the bill until "+DateToStr(now+30);

Winni
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 07, 2022, 04:41:11 pm
No, but floating point math, like +1.0 or even 1/86400 etc is often done with it.

Bravo Marcov!

Example:

s := "Please pay the bill until "+DateToStr(now+30);

That's straight floating point maths, absolutely nothing to do with the number of bits in the representation.

But having the number of fractional bits nibbled away the further the current data moves from the epoch is hardly a good idea.

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 07, 2022, 04:55:04 pm
Many devices now measure distances by the time it takes to bounce a signal off of it. So, if you want to make a better unit, you should at least take those time frames and that resolution into account. And what we have is already a big update over the 18.2 Hz timer tick of the original IBM PC, the default for a long time.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 07, 2022, 05:15:34 pm
Many devices now measure distances by the time it takes to bounce a signal off of it. So, if you want to make a better unit, you should at least take those time frames and that resolution into account. And what we have is already a big update over the 18.2 Hz timer tick of the original IBM PC, the default for a long time.

If I wanted to "make a better unit" I'd use the longstanding IBM mainframe convention of an integer where the LSB represents some unreasonably small timescale (e.g. 1 nSec) with the lowest bit actually guaranteed to increment (e.g. every 1024 x 1024 nSec) being implementation-defined.

However I'm /not/ out to make a better unit, I'm just interested in why extended type isn't being used for what it supposedly an opaque floating point type. Surely nobody in their right mind bit-twiddles floating point numbers?

I note Marco's comment elsewhere yesterday that there's always twits who write in assembler expecting it to be portable. But even there floating point manipulation was done either by hardware or by predefined libraries.

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: PascalDragon on June 08, 2022, 09:53:59 am
Because Delphi did so. And the accuracy of Double is probably sufficient for the intended purpose.

Hmm. But we're both  further from the epoch (1900?) than when Borland selected it (late 90s?) and expecting to be able to use smaller intervals for timeouts etc. as computers speed up (assuming, of course, that that trend continues).

I need to correct my statement a bit: it's not a Double, because Delphi did so, but because Microsoft did so for Visual Basic and Excel. TDateTime is fully interchangeable with the DATE type used in OLE which is described for the VARIANT struct here (https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-variant):

Quote
Type: DATE A date and time value. Dates are represented as double-precision numbers, where midnight, January 1, 1900 is 2.0, January 2, 1900 is 3.0, and so on.

Also Delphi's documentation mentions this:

Quote
The maximal correct date supported by TDateTime values is limited to 12/31/9999 23:59:59:999.

So that's plenty of time for normal use cases...

Since a TDateTime should be treated as opaque, is binary compatibility that important?

Yes, due to above point.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 08, 2022, 10:05:00 am
I need to correct my statement a bit: it's not a Double, because Delphi did so, but because Microsoft did so for Visual Basic and Excel. TDateTime is fully interchangeable with the DATE type used in OLE which is described for the VARIANT struct here (https://docs.microsoft.com/en-us/windows/win32/api/oaidl/ns-oaidl-variant):

Quote
Type: DATE A date and time value. Dates are represented as double-precision numbers, where midnight, January 1, 1900 is 2.0, January 2, 1900 is 3.0, and so on.

OK, that's a fairly persuasive reason, at least for the default type and library routines.

Some people might argue that an alternative floating-point representation might be preferable, but in light of the limited portability of 80-bit extendeds that's probably not a viable solution.

I once thrashed out a workable 64-bit (?) representation which gave both high resolution and a limit several 10's of thousands of years in the future, only to be told by my boss that the coverage wasn't sufficient for his plans for World domination.

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: marcov on June 08, 2022, 10:27:46 am
That's straight floating point maths, absolutely nothing to do with the number of bits in the representation.

But having the number of fractional bits nibbled away the further the current data moves from the epoch is hardly a good idea.

Double is the highest shared floating point number. But maybe if you implement soft float for 128-bt float, that can be used. (extended is not portable enough to really be a solution)
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 08, 2022, 10:34:41 am
Double is the highest shared floating point number. But maybe if you implement soft float for 128-bt float, that can be used. (extended is not portable enough to really be a solution)

My previous point stands: nobody in their right mind gets involved with bit-twiddling floating points :-)

Although I suppose it will have to be done at some point...

I did have to decode floating point stuff from an HP instrument a few months ago. Great company, but they also had the big-company "not-invented-here" syndrome with massive internal incompatibility between equipment. Still better than Tektronix, where if you wanted to capture output you had to OCR an Epson-format bitmap.

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: marcov on June 08, 2022, 10:41:09 am
I did have to decode floating point stuff from an HP instrument a few months ago. Great company, but they also had the big-company "not-invented-here" syndrome with massive internal incompatibility between equipment. Still better than Tektronix, where if you wanted to capture output you had to OCR an Epson-format bitmap.

128-bit is not not invented here. To my knowledge hardware sits in this room that has hardware 128-bit FP.

Tektronix I know mostly from large, card based multi channel scopes.

Extended only works on 32-bit x86 and x86_64 *nix systems (status on win64 is murky)
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 08, 2022, 10:42:12 am
Many devices now measure distances by the time it takes to bounce a signal off of it. So, if you want to make a better unit, you should at least take those time frames and that resolution into account. And what we have is already a big update over the 18.2 Hz timer tick of the original IBM PC, the default for a long time.

If I wanted to "make a better unit" I'd use the longstanding IBM mainframe convention of an integer where the LSB represents some unreasonably small timescale (e.g. 1 nSec) with the lowest bit actually guaranteed to increment (e.g. every 1024 x 1024 nSec) being implementation-defined.

However I'm /not/ out to make a better unit, I'm just interested in why extended type isn't being used for what it supposedly an opaque floating point type. Surely nobody in their right mind bit-twiddles floating point numbers?

I note Marco's comment elsewhere yesterday that there's always twits who write in assembler expecting it to be portable. But even there floating point manipulation was done either by hardware or by predefined libraries.

MarkMLl

Ah, well, I don't know about that (https://en.wikipedia.org/wiki/Fast_inverse_square_root)...

Although you can argue that it was using the floating-point hardware in unusual ways.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 08, 2022, 10:59:59 am
I did have to decode floating point stuff from an HP instrument a few months ago. Great company, but they also had the big-company "not-invented-here" syndrome with massive internal incompatibility between equipment. Still better than Tektronix, where if you wanted to capture output you had to OCR an Epson-format bitmap.

128-bit is not not invented here. To my knowledge hardware sits in this room that has hardware 128-bit FP.

Tektronix I know mostly from large, card based multi channel scopes.

Extended only works on 32-bit x86 and x86_64 *nix systems (status on win64 is murky)

128 bit FP is a quite common format for vector units. Many game computers, like the XBox 360 and PS/3 have those. AMD64, not so much. Although you could use fixed-point calculations with the SIMD units.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 08, 2022, 11:00:45 am
Ah, well, I don't know about that (https://en.wikipedia.org/wiki/Fast_inverse_square_root)...

Yes, I've come across that inside Crays. But I'd suggest that that's still the sort of thing you're more likely to use for high-performance integer work (which, when push comes to shove, is what graphics and signal processing are) and that the number of situations in which one should get involved in bit-twiddling things like the long-standardised IEEE format are minimal.

But I have unbounded respect for people who could build a calculator implementing CORDIC with a magnetostrictive delay-line and a few diodes.

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: marcov on June 08, 2022, 11:06:56 am
128 bit FP is a quite common format for vector units. Many game computers, like the XBox 360 and PS/3 have those.

Afaik the machine I was talking about, is an older uncle of those, a IMac with a G5.

Quote
AMD64, not so much. Although you could use fixed-point calculations with the SIMD units.

Maybe. 64-bit,64-bit pairs or so.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 08, 2022, 11:51:40 am
Maybe. 64-bit,64-bit pairs or so.

That would fit the TDateTime format. Although it would make calculations that simply add or substract hours or seconds slower.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: marcov on June 08, 2022, 01:03:55 pm
btw, I send records with tdatetime in it over TCP between FPC and Delphi apps......
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: PascalDragon on June 08, 2022, 02:24:24 pm
Double is the highest shared floating point number. But maybe if you implement soft float for 128-bt float, that can be used. (extended is not portable enough to really be a solution)

My previous point stands: nobody in their right mind gets involved with bit-twiddling floating points :-)

Well, we could definitely use such people, because for FPC we need software 128-bit FP support so that we can fully support cross compilation from platforms that don't support Extended (including x86_64-win64) to those that do. And while basic routines are already available functions like exp and ln as well as the trigonometry ones are missing...
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 08, 2022, 02:40:36 pm
Well, we could definitely use such people, because for FPC we need software 128-bit FP support so that we can fully support cross compilation from platforms that don't support Extended (including x86_64-win64) to those that do. And while basic routines are already available functions like exp and ln as well as the trigonometry ones are missing...

I'm currently twiddling factors and primitive roots: my brain hurts enough already :-)

I don't know who they are, but there's some useful stuff at https://www.geeksforgeeks.org/

If https://en.wikipedia.org/wiki/Quadruple-precision_floating-point_format#Hardware_support is to be believed, there's very little that actually has hardware support for 128-bit IEEE maths. Which could be interpreted either as indicating that nobody's really bothered about that level of precision (notwithstanding my original question), or that software support is urgently needed.

In the latter case, surely it's a "Summer of Code" job for some bright undergrads?

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: SymbolicFrank on June 09, 2022, 01:42:13 pm
Double is the highest shared floating point number. But maybe if you implement soft float for 128-bt float, that can be used. (extended is not portable enough to really be a solution)

My previous point stands: nobody in their right mind gets involved with bit-twiddling floating points :-)

Well, we could definitely use such people, because for FPC we need software 128-bit FP support so that we can fully support cross compilation from platforms that don't support Extended (including x86_64-win64) to those that do. And while basic routines are already available functions like exp and ln as well as the trigonometry ones are missing...

There still isn't native support for BigInt either, so a general library for arbitrary precision fixed and floating-point would be awesome. I started both a few times and translated one halfway from Delphi, but it was too much work for what I needed it for. The last time I wrote a working floating-point library was before floating-pont hardware was common. So, long ago :)
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: PascalDragon on June 10, 2022, 09:19:44 am
There still isn't native support for BigInt either, so a general library for arbitrary precision fixed and floating-point would be awesome. I started both a few times and translated one halfway from Delphi, but it was too much work for what I needed it for. The last time I wrote a working floating-point library was before floating-pont hardware was common. So, long ago :)

Neither a BigInt library nor support for arbitrary precision fixed and floating point arithmetic is important for cross compilation. Support for 128-bit floating point however is.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MarkMLl on June 10, 2022, 09:30:08 am
Neither a BigInt library nor support for arbitrary precision fixed and floating point arithmetic is important for cross compilation. Support for 128-bit floating point however is.

I'd not presume to argue with that bit as a reality check: am I correct in believing that only the POWER architecture support this in hardware (possibly with RISCV in the future)? And however much I've favoured alternative architectures in the past, is that one really likely to remain viable?

MarkMLl
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: marcov on June 10, 2022, 10:10:33 am
I'd not presume to argue with that bit as a reality check: am I correct in believing that only the POWER architecture support this in hardware (possibly with RISCV in the future)? And however much I've favoured alternative architectures in the past, is that one really likely to remain viable?

The compiler now uses extended that is not crossplatform to do calculate to create double constants.

A generic 128-bit soft fpu would fix that crossplatform issue, regardless of hardware support.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: PascalDragon on June 10, 2022, 01:16:34 pm
Neither a BigInt library nor support for arbitrary precision fixed and floating point arithmetic is important for cross compilation. Support for 128-bit floating point however is.

I'd not presume to argue with that bit as a reality check: am I correct in believing that only the POWER architecture support this in hardware (possibly with RISCV in the future)? And however much I've favoured alternative architectures in the past, is that one really likely to remain viable?

It's not about hardware support! It's about compiling from a system that does not support 80-bit floating point to a system that does. And instead of using 80-bit it's a logical step to simply use the next bigger size, namely 128-bit.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MathMan on June 11, 2022, 12:16:34 pm
Double is the highest shared floating point number. But maybe if you implement soft float for 128-bit float, that can be used. (extended is not portable enough to really be a solution)

My previous point stands: nobody in their right mind gets involved with bit-twiddling floating points :-)

Well, we could definitely use such people, because for FPC we need software 128-bit FP support so that we can fully support cross compilation from platforms that don't support Extended (including x86_64-win64) to those that do. And while basic routines are already available functions like exp and ln as well as the trigonometry ones are missing...

"software 128-bit FP support" is a very generic term. Are the exact requirements noted down somewhere? Depending on these the task can vary from several man days to man years ...

* full implementation in FPC, or wrapper for an existing FP128 library?
* 32/64 bit and little-/big-endian architecture support?
* based on IEEE754?
* exposure of an internal, more efficient format too?
* designed to allow replacement of some kernel functions by asm routines?
* how much trade is allowed between exactness and speed?
* ...

Don't get me wrong - I'm not committing to anything here (yet)! I'm just a hobby programmer who's solely developing things for his own amusement. But I recently started explorations into FP128 based on IEEE754-2008 and this may coincide with my own ambitions.

Beside that, mmartin has recently announced an FP128 library, following the IEEE754 - however also his version is only covering basic functionality and does not include the desired elementary functions like ln, exp, etc.

Cheers,
MathMan
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: PascalDragon on June 13, 2022, 03:36:01 pm
"software 128-bit FP support" is a very generic term. Are the exact requirements noted down somewhere? Depending on these the task can vary from several man days to man years ...

* full implementation in FPC, or wrapper for an existing FP128 library?
* 32/64 bit and little-/big-endian architecture support?
* based on IEEE754?
* exposure of an internal, more efficient format too?
* designed to allow replacement of some kernel functions by asm routines?
* how much trade is allowed between exactness and speed?
* ...

We already have the core routines in rtl/inc/softfpu.pp (which is based on IEEE754; usable using the units sfpu128 and ufloat128) as such any implementation of the additional functions must work together with those. External libraries are a no-go, the license must be compatible to the RTL's (LGPL with static linking exception) and due to this being especially necessary for cross compilation a full Pascal implementation that works correctly in (16/)32/64-bit in both big and little endian is a necessity. As a first step exactness is more important than speed.
Title: Re: DateUtils.Inc* with double instead on Int64
Post by: MathMan on June 14, 2022, 10:51:36 am
"software 128-bit FP support" is a very generic term. Are the exact requirements noted down somewhere? Depending on these the task can vary from several man days to man years ...

* full implementation in FPC, or wrapper for an existing FP128 library?
* 32/64 bit and little-/big-endian architecture support?
* based on IEEE754?
* exposure of an internal, more efficient format too?
* designed to allow replacement of some kernel functions by asm routines?
* how much trade is allowed between exactness and speed?
* ...

We already have the core routines in rtl/inc/softfpu.pp (which is based on IEEE754; usable using the units sfpu128 and ufloat128) as such any implementation of the additional functions must work together with those. External libraries are a no-go, the license must be compatible to the RTL's (LGPL with static linking exception) and due to this being especially necessary for cross compilation a full Pascal implementation that works correctly in (16/)32/64-bit in both big and little endian is a necessity. As a first step exactness is more important than speed.

Thanks for the clarification PascalDragon. I'll take a look at rtl/inc/softfpu.pp, sfpu128 & ufloat128 to understand exactly what "core routines" are available and what will be required for implementation of elementary functons.
TinyPortal © 2005-2018