Wikipedia:Reference desk/Archives/Computing/2021 May 7

Computing desk
< May 6 << Apr | May | Jun >> Current desk >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 7

edit

Arabic-style numbering of endnotes in OpenOffice

edit

By default, endnotes in OpenOffice text documents come out numbered i, ii, iii, ... . Is there a way to have them numbered 1, 2, 3, ...? Also, they are collected on a new page at the end; is there a way to put them in a Notes section that does not start on a new page? OpenOffice Help mumbles something about "Choose Format - Sections - Options button Footnotes/Endnotes tab", but Sections is greyed out in the Format menu. It also mentions "Spin button own format — Select the numbering style for the endnotes", but I see no spin button. (This is Apache OpenOffice 4.1.10 for Darwin x86_64.)  --Lambiam 13:13, 7 May 2021 (UTC)[reply]

I have found how to make the numbers Arabic (via Tools – Footnotes/Endnotes...), but the question of moving the collected endnotes from their separated page to a Notes section remains.  --Lambiam 13:34, 7 May 2021 (UTC)[reply]

Relative efficiency of various floating point types

edit

Lets say you have three programs, all identical EXCEPT for the fact that one uses a single-precision floats, another double precision, and the third long doubles. Also assume that all three types are distinct, with sizeof(float) < sizeof(double) < sizeof(long double). All things being equal, would each program perform roughly the same? Or will operations upon a float execute faster than the others due to differences in register and bus sizes? Earl of Arundel (talk) 22:27, 7 May 2021 (UTC)[reply]

Long answer: you need to examine the architecture manual for your processor.
Tailored answer: If the system is true 64 bit (data bus + CPU), then any 64 bit operation will be as quick as, or quicker than, a smaller numbers* of bits. Larger operands will be slower.
Simple answer: for a 64-bit machine, assume that sizeof(long double) = 64, then all will be the same speed.
*Storing a small number may require a fetch-update-save whereas storing a native length number should just be a save operations.
HTH, Martin of Sheffield (talk) 22:39, 7 May 2021 (UTC)[reply]
Thanks! All (two) 64-bit machines I've tested thus far show long doubles as being 16 bytes wide, 80 bits of mantissa. At any rate, you seem to be confirming my suspicion. Maybe defaulting to a 64-bit double would be the best route to go. It's precision enough for most application anyway and seems pretty widely supported.
Earl of Arundel (talk) 23:08, 7 May 2021 (UTC)[reply]
Long double that I'm familiar with should be a total of 80 bits, not 80-bit mantissa. Anyhow that will be slower than 64-bit double on a 64-bit machine. And see Extended precision. Bubba73 You talkin' to me? 04:50, 8 May 2021 (UTC)[reply]
Ah, right, 80 bit doubles use 64 bits of mantissa. Well maybe I should just put together some tests for comparison then. Thanks! Earl of Arundel (talk) 18:03, 8 May 2021 (UTC)[reply]

These are some measurements I did on a 80387 many years ago (number per second):

 Type                Addition    Mult.     Division 
 extended (80 bits)  162,000    153,000    128,000
 double   (64 bits)  222,000    208,000    162,000
 single   (32 bits)  242,000    230,000    172,000   

Bubba73 You talkin' to me? 22:34, 8 May 2021 (UTC)[reply]

Tided up the table a bit. My first PC was an Amstrad 8086-based effort, and I longed to stick an 8087 in the empty co-pro socket: until I read the Intel manual and realised you had to be really good at maths to code for it, and it would have been 8086 Assembler anyway... happy days. MinorProphet (talk) 01:42, 9 May 2021 (UTC)[reply]
The results I'm getting look even worse. Three arrays, each with 100,000 elements.
 -- Addition --
 32-bit: 305 ms
 64-bit: 311 ms
 80-bit: 730 ms
 -- Multiplication --
 32-bit: 337 ms
 64-bit: 304 ms
 80-bit: 10345 ms
 -- Division --
 32-bit: 596 ms
 64-bit: 639 ms
 80-bit: 11585 ms
So I may just stick with 64-bit doubles after all. It's a good enough balance between speed and precision anyway. Earl of Arundel (talk) 03:03, 9 May 2021 (UTC)[reply]
If you're writing a real program, the proper order of things is: 1) Write it 2) Make sure it works correctly 3) Optimize if you need to. For all you know it may make no difference on resonably-modern systems because something like I/O will be the bottleneck. Depending on language, compiler/interpreter optimizations may also do much of the work for you. --47.155.96.47 (talk) 17:18, 9 May 2021 (UTC)[reply]
Thanks, and yes I am aware of that technique. I was really just wondering if I could justify using long doubles by default in my programs. Seeing that they can be more than 35 times slower than 64-bit doubles, I honestly don't think I can! Maybe for some specialty application, but otherwise it just isn't worth the performance penalties. Earl of Arundel (talk) 17:37, 9 May 2021 (UTC)[reply]
The figure of 35x slower doesn't look right to me. Maybe your system doesn't do the 80-bit type natively. But don't use the 80-bit ones unless you need the extra precision. Bubba73 You talkin' to me? 01:44, 11 May 2021 (UTC)[reply]
See this from long double: "As with C's other floating-point types, it may not necessarily map to an IEEE format. " That may be what is happening. Bubba73 You talkin' to me? 01:48, 11 May 2021 (UTC)[reply]
(And see Extended precision). Bubba73 You talkin' to me? 01:50, 11 May 2021 (UTC)[reply]