From: pito <pi...@vo...> - 2010-08-29 16:32:54
|
Leon, simple testing of the floats f*, f/. Some cases results are in error. It seems division is sensitive. Not sure about the result's sign, however the result shall be 31415 in all cases. ------------------- \ test1 float small and large numbers \ needs float constant _pi marker _testfloat_ : test1 10000 s>f fdup fdup fdup fdup fdup f* f* f* f* f* _pi fswap f/ 10000 s>f fdup fdup fdup fdup fdup fdup f* f* f* f* f* f* f* f>s . ( the result shall be 31415 ) ; : test2 _pi 10000 s>f f/ 10000 s>f f/ 10000 s>f fdup fdup f* f* f* f>s . ( the result shall be 31415 ) ; : test3 _pi 10000 s>f f/ 10000 s>f f/ 10000 s>f f/ 10000 s>f fdup fdup fdup f* f* f* f* f>s . ( the result shall be 31415 ) ; : test4 -10000 s>f fdup fdup fdup fdup fdup f* f* f* f* f* _pi fswap f/ 10000 s>f fdup fdup fdup fdup fdup fdup f* f* f* f* f* f* f* f>s . ( the result shall be 31415 ) ; : test5 _pi -10000 s>f f/ 10000 s>f f/ -10000 s>f fdup fdup f* f* f* f>s . ( the result shall be 31415 ) ; : test6 _pi -10000 s>f f/ 10000 s>f f/ 10000 s>f f/ -10000 s>f fdup fdup fdup f* f* f* f* f>s . ( the result shall be -31415 ) ; ------------ Pito |
From: Leon N M. <leo...@gm...> - 2010-08-29 17:17:40
|
I don't have my device handy so I can't test your code. Could you be a little more clear about which ones failed, what the results are supposed to be, and what the results actually are? (When you write "the result shall be -31415", is that what it's supposed to be, what it actualy is, or something else?) It looks like you're dividing and then multiplying by very large powers of 10. I wouldn't be surprised if you loose some significant figures by doing this. -Leon |
From: pito <pi...@vo...> - 2010-08-29 18:01:10
|
The test cases are designed specifically to se how it handles large and small numbers. The cases 1-3 are the same as 4-6, the later have only minus sign with those 10000 numbers. All the results shall be by design the integer number 31415 (visualised by "10000 x Pi" - as we do not have float format yet). The Pi is simply multiplied or/and divided by large numbers (as we do not have float input yet, it is done by several multiplication/division by 10000). The results are: > test1 31415 ok > test2 31415 ok > test3 |significand| > 16777215 Here the sign is chabged only: > test4 |significand| > 16777215 > test5 31438 ok > test6 |significand| > 16777215 > My current understanding is the division is cousing issues. The lost of significant figures shall not be the case - see the test 1: tmp = pi / (10000^5) pi = tmp * 10000^6 (correct result 31415). The test 2: tmp = pi / 10000 / 10000 pi = tmp * 10000^3 (correct result 31415). Te test 3: tmp = pi / 10000 / 10000 /10000 pi = tmp * 10000^4 (error). The test4-6 are same as the above one, but with minus sign at 10000. So the result shall be 31415 (when ignoring the sign). As you may see from previous test the f/ is sensitive to signs of the operands and gives unpecise results - see for example test5 result. Pito. ----- PŮVODNÍ ZPRÁVA ----- Od: "Leon N Maurer" <leo...@gm...> Komu: amf...@li... Předmět: Re: [Amforth-devel] Float testing - small/large numbers Datum: 29.8.2010 - 19:17:31 > I don't have my device handy so I can't test your > code. Could you be a little > more clear about which ones failed, what the > results are supposed to be, and > what the results actually are? (When you write > "the result shall be -31415", > is that what it's supposed to be, what it actualy > is, or something else?) > > It looks like you're dividing and then multiplying > by very large powers of 10. > I wouldn't be surprised if you loose some > significant figures by doing this. > -Leon > > ------------------------------------------------------------------------------ > > Sell apps to millions through the Intel(R) > Atom(Tm) Developer Program > Be part of this innovative community and reach > millions of netbook users > worldwide. Take advantage of special opportunities > to increase revenue and > speed time-to-market. Join now, and jumpstart your > future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Amforth-devel mailing list > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel |
From: pito <pi...@vo...> - 2010-08-29 18:33:45
|
Leon, or, to make it simple: Q: why the test1 gives a correct result (31415) and the test4 gives an error (|significand| > 16777215). The test1 is the same as the test4, the only difference is the test4 has minus10000 as the first multiplicand. Pito ----- PŮVODNÍ ZPRÁVA ----- Od: "pito" <pi...@vo...> Komu: leo...@gm..., amf...@li... Předmět: Re: [Amforth-devel] Float testing - small/large numbers Datum: 29.8.2010 - 20:01:01 > The test cases are designed specifically to se how > it handles large > and small numbers. The cases 1-3 are the same as > 4-6, the later have > only minus sign with those 10000 numbers. All the > results shall be > by design the integer number 31415 (visualised by > "10000 x Pi" - as > we do not have float format yet). The Pi is simply > multiplied or/and > divided by large numbers (as we do not have float > input yet, it is > done by several multiplication/division by 10000). > The results are: > > test1 > 31415 ok > > test2 > 31415 ok > > test3 > |significand| > 16777215 > > Here the sign is chabged only: > > test4 > |significand| > 16777215 > > test5 > 31438 ok > > test6 > |significand| > 16777215 > > > > My current understanding is the division is > cousing issues. The lost > of significant figures shall not be the case - see > the test 1: > > tmp = pi / (10000^5) > pi = tmp * 10000^6 (correct result 31415). > > The test 2: > > tmp = pi / 10000 / 10000 > pi = tmp * 10000^3 (correct result 31415). > > Te test 3: > > tmp = pi / 10000 / 10000 /10000 > pi = tmp * 10000^4 (error). > > The test4-6 are same as the above one, but with > minus sign at 10000. > So the result shall be 31415 (when ignoring the > sign). > > As you may see from previous test the f/ is > sensitive to signs of > the operands and gives unpecise results - see for > example test5 > result. > > Pito. > > > > > ----- PŮVODNÍ ZPRÁVA ----- > Od: "Leon N Maurer" <leo...@gm...> > Komu: amf...@li... > Předmět: Re: [Amforth-devel] Float testing - > small/large numbers > Datum: 29.8.2010 - 19:17:31 > > > I don't have my device handy so I can't test > > your > > > code. Could you be a little > > more clear about which ones failed, what the > > results are supposed to be, and > > what the results actually are? (When you write > > "the result shall be -31415", > > is that what it's supposed to be, what it > > actualy > > > is, or something else?) > > > > It looks like you're dividing and then > > multiplying > > > by very large powers of 10. > > I wouldn't be surprised if you loose some > > significant figures by doing this. > > -Leon > > > > ------------------------------------------------------------------------------ > > > > > > Sell apps to millions through the Intel(R) > > Atom(Tm) Developer Program > > Be part of this innovative community and reach > > millions of netbook users > > worldwide. Take advantage of special > > opportunities > > > to increase revenue and > > speed time-to-market. Join now, and jumpstart > > your > > > future. > > http://p.sf.net/sfu/intel-atom-d2d > > _______________________________________________ > > Amforth-devel mailing list > > Amf...@li... > > https://lists.sourceforge.net/lists/listinfo/amforth-devel > > > > > ------------------------------------------------------------------------------ > > Sell apps to millions through the Intel(R) > Atom(Tm) Developer Program > Be part of this innovative community and reach > millions of netbook users > worldwide. Take advantage of special opportunities > to increase revenue and > speed time-to-market. Join now, and jumpstart your > future. > http://p.sf.net/sfu/intel-atom-d2d > _______________________________________________ > Amforth-devel mailing list > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel |
From: Leon N M. <leo...@gm...> - 2010-08-30 02:15:02
|
That's a good way to boil it down. It defintely shouldn't be doing that -- hopefully I'll be able to look in to it tomorrow. -Leon >Sunday 29 August 2010 >From: "pito" <pi...@vo...> >Subject: Re: [Amforth-devel] Float testing - small/large numbers > Leon, or, to make it simple: > Q: why the test1 gives a correct result (31415) and the test4 gives > an error (|significand| > 16777215). > The test1 is the same as the test4, the only difference is the test4 > has minus10000 as the first multiplicand. > Pito |
From: pito <pi...@vo...> - 2010-08-30 11:09:03
|
Leon, I uploaded in other post an update of useful float constnats (these constants are useful till we will have input and output of float numbers). However it freezes when uploading (e.g. when compiling _third) so it seems the f/ is cousing a problem. Try it plz. Pito > That's a good way to boil it down. It defintely > shouldn't be doing that -- > hopefully I'll be able to look in to it tomorrow. > -Leon |
From: pito <pi...@vo...> - 2010-08-30 11:37:37
|
Some errors when compiling float constants: > 1074 s>f 2251 s>f f/ fconstant _log3 |significand| > 16777215 > 10691 s>f 462 s>f f/ fconstant _e**pi |significand| > 16777215 > _1e-6 1000 s>f f/ fconstant _1e-9 |significand| > 16777215 P. |
From: Leon N. M. <leo...@gm...> - 2010-08-30 17:42:24
|
Ok, that bug should be fixed -- the new version of the code is up on http://github.com/lnmaurer/amforth-float Below are some of Pito's examples -- now working. Thanks again for catching this. In answer to an earlier question -- I think double length floats would be trickier to do because there aren't words around to manipulate them. My priority is defiantly getting the other words from the floating point wordset done, followed by some from the floating point extended wordset (including functions like sine, cos, etc.) -Leon -Leon > 355 s>f 113 s>f f/ fconstant _pi ok > _pi 10000 s>f f/ 10000 s>f f/ 10000 s>f f/ 10000 s>f fdup fdup fdup f* f* f* f* f>s . 31415 ok > 1074 s>f 2251 s>f f/ fconstant _log3 ok > _log3 1000 s>f f* f>s . 477 ok > 10691 s>f 462 s>f f/ fconstant _e**pi ok > _e**pi 1000 s>f f* f>s . 23140 ok |
From: pito <pi...@vo...> - 2010-08-30 21:20:05
|
Leon, Thanks! The results of the test1-6 (all results shall be equal 31415, ignoring sign): > test1 31415 ok > test2 31415 ok > test3 31415 ok > test4 31396 ok > test5 31438 ok > test6 -31434 ok > The test4-6 are done with negative koef. You may see an error. One important thing - in order to load float lib you have to add the word d= into your compilation. Pito ----- PŮVODNÍ ZPRÁVA ----- Od: "Leon Nathaniel Maurer" <leo...@gm...> Komu: amf...@li... Předmět: Re: [Amforth-devel] Float testing - small/large numbers Datum: 30.8.2010 - 19:42:28 > Ok, that bug should be fixed -- the new version of > the code is up on > > http://github.com/lnmaurer/amforth-float > > Below are some of Pito's examples -- now working. > Thanks again for catching > this. > > In answer to an earlier question -- I think double > length floats would be > trickier to do because there aren't words around > to manipulate them. My > priority is defiantly getting the other words from > the floating point wordset > done, followed by some from the floating point > extended wordset (including > functions like sine, cos, etc.) > > -Leon > > -Leon > > > 355 s>f 113 s>f f/ fconstant _pi > ok > > _pi 10000 s>f f/ 10000 s>f f/ 10000 s>f f/ 10000 > > s>f fdup fdup fdup f* f* f* > > f* f>s . > 31415 ok > > 1074 s>f 2251 s>f f/ fconstant _log3 > ok > > _log3 1000 s>f f* f>s . > 477 ok > > 10691 s>f 462 s>f f/ fconstant _e**pi > ok > > _e**pi 1000 s>f f* f>s . > 23140 ok > > ------------------------------------------------------------------------------ > > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > Amforth-devel mailing list > Amf...@li... > https://lists.sourceforge.net/lists/listinfo/amforth-devel |
From: pito <pi...@vo...> - 2010-08-30 21:46:45
|
Leon, I think there is an issue with negative numbers: > -1 s>f fconstant _-1 >>>> define 1.0 ok > 1 s>f fconstant _1 >>>> define -1.0 ok > _1 _pi f* _1e4 f* f>s . >>>> 1.0 * pi * 1.0E4 = 31415 31415 ok > _-1 _pi f* _1e4 f* f>s . >>>>> -1.0 * pi * 1.0E4 = -31426 -31426 ok > It cannot be caused by of a rounding error accumulating or loosing a valid digits. Some minor bug somewhere.. P. > > Ok, that bug should be fixed -- the new version > > of > > > the code is up on > > > > http://github.com/lnmaurer/amforth-float > > > > Below are some of Pito's examples -- now > > working. |
From: Leon N. M. <leo...@gm...> - 2010-08-30 21:48:44
|
On Monday, August 30, 2010 04:19:55 pm pito wrote: > The test4-6 are done with negative koef. You may see an error. > One important thing - in order to load float lib you have to add > the word d= into your compilation. > Pito I think 4-6 are getting the right results. test4 has (-1)^6=1, test5 has (-1)^4=1, and test6 has (-1)^5=-1. Commented out code for d= has been in the float.fth file in case it wasn't already installed. -Leon |
From: pito <pi...@vo...> - 2010-08-30 22:19:29
|
Leon, the results of tests 4-6 are from what I see quite different (+/- 19) against the correct result =31415: > test1 31415 ok > test2 31415 ok > test3 31415 ok > test4 31396 ok > test5 31438 ok > test6 -31434 ok > I think the difference is too big for a single precision float..P. ----- PŮVODNÍ ZPRÁVA ----- Od: "Leon Nathaniel Maurer" <leo...@gm...> Komu: "pito" <pi...@vo...> Předmět: Re: [Amforth-devel] Float testing - small/large numbers Datum: 30.8.2010 - 23:48:51 > On Monday, August 30, 2010 04:19:55 pm pito wrote: > > The test4-6 are done with negative koef. You may > > see an error. > > > One important thing - in order to load float lib > > you have to add > > > the word d= into your compilation. > > Pito > > I think 4-6 are getting the right results. test4 > has (-1)^6=1, test5 has > (-1)^4=1, and test6 has (-1)^5=-1. > > Commented out code for d= has been in the > float.fth file in case it wasn't > already installed. > > -Leon |
From: Leon N. M. <leo...@gm...> - 2010-09-01 00:41:31
|
This should now be fixed: > 1 s>f _pi f* 1000000. d>f f* f>d d. 3141592 ok > -1 s>f _pi f* 1000000. d>f f* f>d d. -3141593 ok the discrepency in the smallest digit is due to the way the fractional part gets truncated (it rounds down). If you look directly at the float (take out the f>d and convert to binary) they are now idenetical except for the sign bit: 01001010001111111011111101100010 11001010001111111011111101100010 It turns out the root cause was something like this: > -13176795. d2/ d. -6588398 ok > 13176795. d2/ d. 6588397 ok Which is how it should work if you think of division by 2 as shifting right, but isn't something I had taken in to account -- a good lesson in how negative numbers are represented. My reposititory has been updated -- keep the tests coming. -Leon On Monday, August 30, 2010 04:46:37 pm you wrote: > Leon, > > I think there is an issue with negative numbers: > > -1 s>f fconstant _-1 >>>> define 1.0 > > ok > > > 1 s>f fconstant _1 >>>> define -1.0 > > ok > > > _1 _pi f* _1e4 f* f>s . >>>> 1.0 * pi * 1.0E4 = 31415 > > 31415 ok > > > _-1 _pi f* _1e4 f* f>s . >>>>> -1.0 * pi * 1.0E4 = -31426 > > -31426 ok > > > It cannot be caused by of a rounding error accumulating or loosing a > valid digits. Some minor bug somewhere.. > P. |
From: pito <pi...@vo...> - 2010-09-01 08:42:16
|
Leon, great! See the test: \ test float small and large numbers f* f/ \ needs float constants marker _tstflt_ 314159265. d>f 100000000. d>f f/ fconstant _pi -314159265. d>f 100000000. d>f f/ fconstant _-pi : prntpi _1e6 _100 f* f* f>d d. ; \ +pi f* f/ : test1 _1e6 fdup fdup fdup fdup f* f* f* f* _pi fswap f/ _1e6 fdup fdup fdup fdup f* f* f* f* f* prntpi ( the result shall be 314159265 ) ; : test2 _pi _1e6 f/ _1e6 f/ _1e6 f/ _1e6 f/ _1e6 f/ _1e6 fdup fdup fdup fdup f* f* f* f* f* prntpi ( the result shall be 314159265 ) ; \ -pi f* f/ : test3 _1e6 fdup fdup fdup fdup f* f* f* f* _-pi fswap f/ _1e6 fdup fdup fdup fdup f* f* f* f* f* prntpi ( the result shall be 314159265 ) ; : test4 _-pi _1e6 f/ _1e6 f/ _1e6 f/ _1e6 f/ _1e6 f/ _1e6 fdup fdup fdup fdup f* f* f* f* f* prntpi ( the result shall be 314159265 ) ; > test1 314159200 ok > test2 314159136 ok > test3 -314159200 ok > test4 -314159136 ok > The magnitude errors caused by single precision (let us hope so..). The next step is to test add and sub. Pito . > > My reposititory has been updated -- keep the tests > coming. > > -Leon > |