06-28-2025, 12:13 AM
(06-27-2025, 05:44 PM)madscijr Wrote:(06-27-2025, 01:45 PM)SMcNeill Wrote: Integer Division (the \ division) is much faster than taking the integer value of normal division, as shown above.
x \ y is faster than INT(x / y). At least, it always has been for me on Windows with the math processors on my PCs and Laptops. Perhaps Linux or Mac handles them differently somehow?
No kidding?
This is very very useful to know for any QB64 / QB64PE programmer, thanks for sharing.
Do we by chance have a FAQ anywhere with these little bits of wisdom collected together?
(06-27-2025, 04:21 PM)Kernelpanic Wrote: Yes, floating-point division can be faster than integer division under certain circumstances, especially if the processor has an efficient floating-point unit (FPU) and the hardware support for floating-point operations is optimized. However, this depends heavily on the specific hardware, the compiler used, and the exact data.
. . .
In summary:
While integer division can be faster in some cases, especially when high precision is not required or when the result needs to be rounded to an integer, floating-point division is often faster when the processor has a well-optimized FPU and the compiler adjusts the code accordingly. The actual speed depends on many factors and can therefore vary.
Hmm... I wonder if there is a way to check the hardware from code, so your program can choose the faster method at runtime, depending on the FPU type detected?
Also when using Integer's the NATIVE REGISTER SIZE is going to be fastest. On modern systems that _INTEGER64 !! Not Integer or Even Long. !!!
Honestly. Unless your doing something really, really performance critical then IMHO it really doesn't matter a lot I usually use DOUBLE as It doesn't very often overflow. !!. The only time I use _byte, integer or long is when I'm doing file parsing then the file format selects the required data type !!!

