📄 readme
字号:
sqrt() 195.1 4732.5 log() 358.0-387.5 3359.2-3390.3 exp() 619.3 4046.4These figures are now somewhat out-of-date. The emulator has becomeprogressively slower for most functions as more of the 80486 featureshave been implemented.----------------------- Accuracy of wm-FPU-emu -----------------------The accuracy of the emulator is in almost all cases equal to or betterthan that of an Intel 80486 FPU.The results of the basic arithmetic functions (+,-,*,/), and fsqrtmatch those of an 80486 FPU. They are the best possible; the error forthese never exceeds 1/2 an lsb. The fprem and fprem1 instructionsreturn exact results; they have no error.The following table compares the emulator accuracy for the sqrt(),trig and log functions against the Turbo C "emulator". For this table,each function was tested at about 400 points. Ideal worst-case resultswould be 64 bits. The reduced Turbo C accuracy of cos() and tan() forarguments greater than pi/4 can be thought of as being related to theprecision of the argument x; e.g. an argument of pi/2-(1e-10) which isaccurate to 64 bits can result in a relative accuracy in cos() ofabout 64 + log2(cos(x)) = 31 bits.Function Tested x range Worst result Turbo C (relative bits)sqrt(x) 1 .. 2 64.1 63.2atan(x) 1e-10 .. 200 64.2 62.8cos(x) 0 .. pi/2-(1e-10) 64.4 (x <= pi/4) 62.4 64.1 (x = pi/2-(1e-10)) 31.9sin(x) 1e-10 .. pi/2 64.0 62.8tan(x) 1e-10 .. pi/2-(1e-10) 64.0 (x <= pi/4) 62.1 64.1 (x = pi/2-(1e-10)) 31.9exp(x) 0 .. 1 63.1 ** 62.9log(x) 1+1e-6 .. 2 63.8 ** 62.1** The accuracy for exp() and log() is low because the FPU (emulator)does not compute them directly; two operations are required.The emulator passes the "paranoia" tests (compiled with gcc 2.3.3 orlater) for 'float' variables (24 bit precision numbers) when precisioncontrol is set to 24, 53 or 64 bits, and for 'double' variables (53bit precision numbers) when precision control is set to 53 bits (aproperly performing FPU cannot pass the 'paranoia' tests for 'double'variables when precision control is set to 64 bits).The code for reducing the argument for the trig functions (fsin, fcos,fptan and fsincos) has been improved and now effectively uses a valuefor pi which is accurate to more than 128 bits precision. As aconsequence, the accuracy of these functions for large arguments hasbeen dramatically improved (and is now very much better than an 80486FPU). There is also now no degradation of accuracy for fcos and fptanfor operands close to pi/2. Measured results are (note that thedefinition of accuracy has changed slightly from that used for theabove table):Function Tested x range Worst result (absolute bits)cos(x) 0 .. 9.22e+18 62.0sin(x) 1e-16 .. 9.22e+18 62.1tan(x) 1e-16 .. 9.22e+18 61.8It is possible with some effort to find very large arguments whichgive much degraded precision. For example, the integer number 8227740058411162616.0is within about 10e-7 of a multiple of pi. To find the tan (forexample) of this number to 64 bits precision it would be necessary tohave a value of pi which had about 150 bits precision. The FPUemulator computes the result to about 42.6 bits precision (the correctresult is about -9.739715e-8). On the other hand, an 80486 FPU returns0.01059, which in relative terms is hopelessly inaccurate.For arguments close to critical angles (which occur at multiples ofpi/2) the emulator is more accurate than an 80486 FPU. For very largearguments, the emulator is far more accurate.Prior to version 1.20 of the emulator, the accuracy of the results forthe transcendental functions (in their principal range) was not asgood as the results from an 80486 FPU. From version 1.20, the accuracyhas been considerably improved and these functions now give measuredworst-case results which are better than the worst-case results givenby an 80486 FPU.The following table gives the measured results for the emulator. Thenumber of randomly selected arguments in each case is about half amillion. The group of three columns gives the frequency of the givenaccuracy in number of times per million, thus the second of thesecolumns shows that an accuracy of between 63.80 and 63.89 bits wasfound at a rate of 133 times per one million measurements for fsin.The results show that the fsin, fcos and fptan instructions returnresults which are in error (i.e. less accurate than the best possibleresult (which is 64 bits)) for about one per cent of all argumentsbetween -pi/2 and +pi/2. The other instructions have a lowerfrequency of results which are in error. The last two columns givethe worst accuracy which was found (in bits) and the approximate valueof the argument which produced it. frequency (per M) ------------------- ---------------instr arg range # tests 63.7 63.8 63.9 worst at arg bits bits bits bits----- ------------ ------- ---- ---- ----- ----- --------fsin (0,pi/2) 547756 0 133 10673 63.89 0.451317fcos (0,pi/2) 547563 0 126 10532 63.85 0.700801fptan (0,pi/2) 536274 11 267 10059 63.74 0.784876fpatan 4 quadrants 517087 0 8 1855 63.88 0.435121 (4q)fyl2x (0,20) 541861 0 0 1323 63.94 1.40923 (x)fyl2xp1 (-.293,.414) 520256 0 0 5678 63.93 0.408542 (x)f2xm1 (-1,1) 538847 4 481 6488 63.79 0.167709Tests performed on an 80486 FPU showed results of lower accuracy. Thefollowing table gives the results which were obtained with an AMD486DX2/66 (other tests indicate that an Intel 486DX producesidentical results). The tests were basically the same as those usedto measure the emulator (the values, being random, were in general notthe same). The total number of tests for each instruction are givenat the end of the table, in case each about 100k tests were performed.Another line of figures at the end of the table shows that most of theinstructions return results which are in error for more than 10percent of the arguments tested.The numbers in the body of the table give the approx number of times aresult of the given accuracy in bits (given in the left-most column)was obtained per one million arguments. For three of the instructions,two columns of results are given: * The second column for f2xm1 givesthe number cases where the results of the first column were for apositive argument, this shows that this instruction gives betterresults for positive arguments than it does for negative. * In thecases of fcos and fptan, the first column gives the results when allcases where arguments greater than 1.5 were removed from the resultsgiven in the second column. Unlike the emulator, an 80486 FPU returnsresults of relatively poor accuracy for these instructions when theargument approaches pi/2. The table does not show those cases when theaccuracy of the results were less than 62 bits, which occurs quiteoften for fsin and fptan when the argument approaches pi/2. This pooraccuracy is discussed above in relation to the Turbo C "emulator", andthe accuracy of the value of pi.bits f2xm1 f2xm1 fpatan fcos fcos fyl2x fyl2xp1 fsin fptan fptan62.0 0 0 0 0 437 0 0 0 0 92562.1 0 0 10 0 894 0 0 0 0 102362.2 14 0 0 0 1033 0 0 0 0 94562.3 57 0 0 0 1202 0 0 0 0 102362.4 385 0 0 10 1292 0 23 0 0 117862.5 1140 0 0 119 1649 0 39 0 0 114962.6 2037 0 0 189 1620 0 16 0 0 116962.7 5086 14 0 646 2315 10 101 35 39 140262.8 8818 86 0 984 3050 59 287 131 224 203662.9 11340 1355 0 2126 4153 79 605 357 321 194863.0 15557 4750 0 3319 5376 246 1281 862 808 268863.1 20016 8288 0 4620 6628 511 2569 1723 1510 330263.2 24945 11127 10 6588 8098 1120 4470 2968 2990 472463.3 25686 12382 69 8774 10682 1906 6775 4482 5474 723663.4 29219 14722 79 11109 12311 3094 9414 7259 8912 1058763.5 30458 14936 393 13802 15014 5874 12666 9609 13762 1526263.6 32439 16448 1277 17945 19028 10226 15537 14657 19158 2034663.7 35031 16805 4067 23003 23947 18910 20116 21333 25001 2620963.8 33251 15820 7673 24781 25675 24617 25354 24440 29433 3032963.9 33293 16833 18529 28318 29233 31267 31470 27748 29676 30601Per cent with error: 30.9 3.2 18.5 9.8 13.1 11.6 17.4Total arguments tested: 70194 70099 101784 100641 100641 101799 128853 114893 102675 102675------------------------- Contributors -------------------------------A number of people have contributed to the development of theemulator, often by just reporting bugs, sometimes with suggestedfixes, and a few kind people have provided me with access in one wayor another to an 80486 machine. Contributors include (to those peoplewho I may have forgotten, please forgive me):Linus TorvaldsTommy.Thorn@daimi.aau.dkAndrew.Tridgell@anu.edu.auNick Holloway, alfie@dcs.warwick.ac.ukHermano Moura, moura@dcs.gla.ac.ukJon Jagger, J.Jagger@scp.ac.ukLennart BenschopBrian Gallew, geek+@CMU.EDUThomas Staniszewski, ts3v+@andrew.cmu.eduMartin Howell, mph@plasma.apana.org.auM Saggaf, alsaggaf@athena.mit.eduPeter Barker, PETER@socpsy.sci.fau.edutom@vlsivie.tuwien.ac.atDan Russel, russed@rpi.eduDaniel Carosone, danielce@ee.mu.oz.aucae@jpmorgan.comHamish Coleman, t933093@minyos.xx.rmit.oz.auBruce Evans, bde@kralizec.zeta.org.auTimo Korvola, Timo.Korvola@hut.fiRick Lyons, rick@razorback.brisnet.org.auRick, jrs@world.std.com ...and numerous others who responded to my request for help witha real 80486.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -