Thread: [Flashforth-devel] Free form number
Brought to you by:
oh2aun
From: Herman A. <exp...@vn...> - 2014-03-26 08:52:37
|
Hi Mike and all, I have an old idea, that would be fine to do in FF. In general text frequently used representation of numbers using delimiter characters to separate the groups of digits. 1,048,576 32'768 ff00 fd12 1001 0010 1110 In this form of a long number is well readable, but unusable directly in forth. We need a forth word to remove all non-number character from the string, then convert the result string to a number. Maybe give the human readable format in a string, then posteriorly convert it: s" 1100 1001" >>number Often would be better solution using a word wich collect the real digits from the input stream until a terminal character, then convert it to a number according to the given base or current base. Example form: #{ 1,048,576} \ decimal ${ ff00 fd12} \ hex %{ 1001 0010 1110} \ binary n{ 32'768} \ in current base All above words leave the result on the stack. What do you think about my conception? BR Attila |
From: Mikael N. <mik...@pp...> - 2014-03-26 17:39:07
|
I could easily extend the FF >number so that it would work as today but just ignore certain punctuation. What would be the best choice for punctuation ? Perhaps the comma character. Or use the period anywhere in number to indicate that it as double number. Not having any punctuation in single numbers. This is how it is described in Forth Programmers Handbook. Single precision number #10,345 %1011,1101,1111,0000 $fad,e Double precision numbers %1011_1101_1111_0000. #10,345. $fade,babe. $f,a,d,e,b,a,b,e. You proposal with separate parsing words can be implemented as an add-on if wanted. BR Mike |
From: Herman A. <exp...@vn...> - 2014-03-26 19:31:13
|
It is perfect solution to extend the >number to ignor the separator. I think the best choice is the underscore character. The comma disturb me a bit, because it is "decimal point" in hungarian notation. :-) Thanks, BR Attila ----- Eredeti üzenet ----- Feladó: Mikael Nordman <mik...@pp...> Dátum: Szerda, Március 26, 2014 6:39 Tárgy: Re: [Flashforth-devel] Free form number Címzett: fla...@li... > I could easily extend the FF >number so that it > would work as today but just ignore certain punctuation. > > What would be the best choice for punctuation ? > Perhaps the comma character. > > Or use the period anywhere in number to indicate that it as double number. > Not having any punctuation in single numbers. This is how > it is described in Forth Programmers Handbook. > > Single precision number > #10,345 > %1011,1101,1111,0000 > $fad,e > > Double precision numbers > %1011_1101_1111_0000. > #10,345. > $fade,babe. > $f,a,d,e,b,a,b,e. > > > You proposal with separate parsing words can be implemented as an > add-on > if wanted. > > BR Mike > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > > _______________________________________________ > Flashforth-devel mailing list > Fla...@li... > |
From: Mike M. <mi...@mo...> - 2014-03-27 06:39:14
|
Forth typically converts a double number when there is ANY of the following punctuation chrs present anywhere in the number , . / - : The exception is a leading - chr which indictes a negative number. See Starting Forth, Leo Brodie. These punctuations support European and US number and time formats, and many others. I see nothing wrong with adding the _ chr. FF 4.8 only recognizes a . chr at the end of the digits, so I needed to write my own number conversion word. A double number format closer to the standard would be nice. Mike Miller Moon Valley Circuits mi...@mo... http://www.moonvalleycircuits.com/ On 3/26/14 10:38 AM, Mikael Nordman wrote: > I could easily extend the FF >number so that it > would work as today but just ignore certain punctuation. > > What would be the best choice for punctuation ? > Perhaps the comma character. > > Or use the period anywhere in number to indicate that it as double number. > Not having any punctuation in single numbers. This is how > it is described in Forth Programmers Handbook. > > Single precision number > #10,345 > %1011,1101,1111,0000 > $fad,e > > Double precision numbers > %1011_1101_1111_0000. > #10,345. > $fade,babe. > $f,a,d,e,b,a,b,e. > > > You proposal with separate parsing words can be implemented as an add-on > if wanted. > > BR Mike > > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/13534_NeoTech > _______________________________________________ > Flashforth-devel mailing list > Fla...@li... > https://lists.sourceforge.net/lists/listinfo/flashforth-devel > > |
From: Mikael N. <mik...@pp...> - 2014-03-27 19:22:22
|
I plan now to do it like this Just one punctuation char for grouping digits. Single precision number #-10.345 %1011.1101.1111.0000 $fad.e Double precision numbers %1011.1101.1111.0000. #-10.345. $fade.babe. Mike Miller, Do you have some code you could share ? For instance on the FF Wiki. You can add new pages there, just a SF account is needed. It would be great to get more community contribution to this open source project. BR Mike On 03/27/2014 08:25 AM, Mike Miller wrote: > Forth typically converts a double number when there is ANY of the following punctuation chrs present anywhere in the number , . / - : > The exception is a leading - chr which indictes a negative number. See Starting Forth, Leo Brodie. > > These punctuations support European and US number and time formats, and many others. I see nothing wrong with adding the _ chr. > > FF 4.8 only recognizes a . chr at the end of the digits, so I needed to write my own number conversion word. > A double number format closer to the standard would be nice. > > > Mike Miller > Moon Valley Circuits > mi...@mo... > http://www.moonvalleycircuits.com/ > > > On 3/26/14 10:38 AM, Mikael Nordman wrote: >> I could easily extend the FF >number so that it >> would work as today but just ignore certain punctuation. >> >> What would be the best choice for punctuation ? >> Perhaps the comma character. >> >> Or use the period anywhere in number to indicate that it as double number. >> Not having any punctuation in single numbers. This is how >> it is described in Forth Programmers Handbook. >> >> Single precision number >> #10,345 >> %1011,1101,1111,0000 >> $fad,e >> >> Double precision numbers >> %1011_1101_1111_0000. >> #10,345. >> $fade,babe. >> $f,a,d,e,b,a,b,e. >> >> >> You proposal with separate parsing words can be implemented as an add-on >> if wanted. >> >> BR Mike >> >> >> ------------------------------------------------------------------------------ >> Learn Graph Databases - Download FREE O'Reilly Book >> "Graph Databases" is the definitive new guide to graph databases and their >> applications. Written by three acclaimed leaders in the field, >> this first edition is now available. Download your free book today! >> http://p.sf.net/sfu/13534_NeoTech >> _______________________________________________ >> Flashforth-devel mailing list >> Fla...@li... >> https://lists.sourceforge.net/lists/listinfo/flashforth-devel >> >> > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Flashforth-devel mailing list > Fla...@li... > https://lists.sourceforge.net/lists/listinfo/flashforth-devel |