On 12/04/08 22:29, Mikolaj Machowski wrote: > Dnia Saturday 12 of April 2008, Tony Mechelynck napisał: >> On 12/04/08 20:29, Mikolaj Machowski wrote: >>> Dnia Saturday 12 of April 2008, Bram Moolenaar napisał: >>>> Here is an update for the floating point patch. The 'g' argument for >>>> printf() was implemented and a few bug fixes. >>>> >>>> This is to be applied to the original source code, without the older >>>> floating point patch. >>> One thing: >>> let a =&1.2 >> echo a >> 1.200000 >> (a Float IIUC) > > 1,200000 " type Float > >>> let b = string(b) >> let b = string(a) >> echo b >> 1.200000 >> (a String IIUC) > > 1,200000 " type String > >>> let c = eval(b) > > E488, but something was done... > >> echo c >> 1200000 >> (a String = '1' . '200000') > > 1 " type Number > > I get different results. I strongly suspect localization (pl_PL) > -> , instead of . as separator. > >> These are expected. > > String isn't really expected. With fully working "translation" (as with > other data types) at the end should be Float. > > > m.
I use C locale, where the decimal point is a period. Evaluating the string "2+2" gives the result 4, because the String has been evaluated as an expression. Similarly, evaluating the String "1.200000", which is also the string-representation of an expression, gives "1200000" which is the result of that expression -- a concatenated String. OTOH, eval("1,200000") gives an error "Trailing characters" because 1,200000 cannot be seen as ONE expression -- i.e., "when we're finished parsing it, there's something left over", namely the comma and everything after it. If you had used ":let c = str2float(b)" then (IIUC -- I didn't try) the result would have come out equal to a. In a "decimal comma" locale, eval('&' . b) wouldn't have worked, you would have had to first replace the comma by a dot. Best regards, Tony. -- For some reason a glaze passes over people's faces when you say "Canada". Maybe we should invade South Dakota or something. -- Sandra Gotlieb, wife of the Canadian ambassador to the U.S. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---