Re: [DUG] Int64 or floating point faster?

2014-08-16 Thread Jolyon Smith
That's curious.  Who are they ?  It doesn't sound like any floating point
implementation I ever came across in Delphi (or anywhere else, for that
matter).  O.o


On 17 August 2014 12:28, Pieter De Wit pie...@insync.za.net wrote:

  Hi Jolyon,

 From memory, they used 2 int32's to make a float - this could have been
 int16's - memory is very vague on this :) The one was used to represent the
 whole numbers and the other was to show the decimal numbers

 Cheers,

 Pieter


 On 17/08/2014 12:05, Jolyon Smith wrote:

 @Pieter - I don't understand what you mean when you say that float was
 int32.int32.  For starters, float is an imprecise term.  If you mean
 single then the entire value was always 32 bit in it's entirety.  If you
 mean double then it was always 64 bit.  What is this in32.int32 type of
 which you speak ?  O.o


 On 17 August 2014 11:52, Jolyon Smith jsm...@deltics.co.nz wrote:

 I think there are too many variables involved to give an answer to this
 question without some of those variables being reduced to known values.

 e.g.  what hardware ?  what version of Delphi ?  x64 target or x86 ?
  what precision of floating point ?

 Having said that, in a quick test knocked up in my Smoketest framework I
 found that Double comfortably outperforms Int64 when compiling for Win32
 but that both Double and Int64 demonstrated improved performance when
 compiling for Win64 and that whilst Double still showed some advantage it
 was not as significant (and in some test runs the difference was
 negligible).

 If you are targeting FireMonkey you will have to bear in mind that the
 back-end compiler is different to the x86/x64 backend, so results obtained
 using the WinXX compilers will not necessarily be indicative of performance
 on the ARM or LLVM platforms.


 Conditions:

  - Delphi XE4
  - Running in a 64-bit Win 7 VM
   - No testing was done for correctness of the results.





  On 16 August 2014 15:30, Ross Levis r...@stationplaylist.com wrote:

   Would I be correct that int64 multiplications would be faster than
 floating point in Delphi?  My app needs to do several million.



  ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@listserver.123.net.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with
 Subject: unsubscribe





 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@listserver.123.net.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with 
 Subject: unsubscribe



 ___
 NZ Borland Developers Group - Delphi mailing list
 Post: delphi@listserver.123.net.nz
 Admin: http://delphi.org.nz/mailman/listinfo/delphi
 Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with
 Subject: unsubscribe

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with 
Subject: unsubscribe

Re: [DUG] Int64 or floating point faster?

2014-08-16 Thread Ross Levis
Single precision would be adequate for what I need.  I didn’t explain it very 
clearly.  My current calculation is like this.

 

Var64bit := Var16bit * Var32bitB div Var32bitC;

If Var64bit  32767 then Var64bit := 32767;

If Var64bit  -32768 then Var64bit := -32768;

Var16bit := Var64bit;

 

I made the target Int64 since Var16bit * Var32bitB can end up bigger than an 
Int32 number.  I believe that forces the compiler to use In64 multiplication.  
Or perhaps this has the same effect...

 

Var32bitA := Int64(Var16bit * Var32bitB) div Var32bitC;

 

The alternative is to store (Var32bitB / Var32bitC) in a Single var.

 

I suppose I should do my own tests if the speed is not so obvious.

 

Ross.

 

From: delphi-boun...@listserver.123.net.nz 
[mailto:delphi-boun...@listserver.123.net.nz] On Behalf Of Jolyon Smith
Sent: Sunday, 17 August 2014 11:52 a.m.
To: NZ Borland Developers Group - Delphi List
Subject: Re: [DUG] Int64 or floating point faster?

 

I think there are too many variables involved to give an answer to this 
question without some of those variables being reduced to known values.

e.g.  what hardware ?  what version of Delphi ?  x64 target or x86 ?  what 
precision of floating point ?

Having said that, in a quick test knocked up in my Smoketest framework I found 
that Double comfortably outperforms Int64 when compiling for Win32 but that 
both Double and Int64 demonstrated improved performance when compiling for 
Win64 and that whilst Double still showed some advantage it was not as 
significant (and in some test runs the difference was negligible).

If you are targeting FireMonkey you will have to bear in mind that the back-end 
compiler is different to the x86/x64 backend, so results obtained using the 
WinXX compilers will not necessarily be indicative of performance on the ARM or 
LLVM platforms.



Conditions:


 - Delphi XE4

 - Running in a 64-bit Win 7 VM

 - No testing was done for correctness of the results.

 

 

 

On 16 August 2014 15:30, Ross Levis r...@stationplaylist.com wrote:

Would I be correct that int64 multiplications would be faster than floating 
point in Delphi?  My app needs to do several million.

 


___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with 
Subject: unsubscribe

 

___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@listserver.123.net.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send an email to delphi-requ...@listserver.123.net.nz with 
Subject: unsubscribe