From: Leon N M. <leo...@gm...> - 2010-09-27 04:35:23
|
Ok, I've added a very rough version of >FLOAT, which takes the address and length of a string and returns a float. For example, here's an 8 character long string starting at address 471 -- first displayed using TYPE, then converted to a float and printed with FS. > 471 8 type 46.3e-42 ok > 471 8 >float fs. 4.6298862E-41 ok It's not so accurate (and it's slow) because it's using some floating point arithmetic where integer arithmetic will do, but I'll deal with that later (I even hope to use a nice conversion algorithm, like <http://portal.acm.org/citation.cfm?id=368376>). Two things: 1) How does exception handling work? >FLOAT is supposed to return FALSE if it's can't convert something to a string, but currently it will just throw an error because NUMBER will throw an error (since NUMBER is used under the hood). I'd like to catch any error NUMBER throws and then return FALSE as required. 2) Currently NUMBER accepts numbers with a leading negative sign, but not a leading positive sign (e.g. -101 works, but +101 causes an error). ANS94 requires floats to work with both, so it would be easier for me if NUMBER works with both. (Does ANS94 say anything about accepting positive signs for integers?) -Leon |