>NUMBER

From: Gary Sprung <gsprung_at_forth.com>
Date: Wed, 13 Dec 2000 10:49:53 -0800

For values of BASE > 10, >NUMBER doesn't reject
the ASCII characters : through ?, returning
instead the values 10 through 15 in the converted
number. The phrase 10 16 WITHIN OR DUP in this
revised >NUMBER fixes the problem:

: >NUMBER ( ud1 c-addr1 u1 -- ud2 c-addr2 u2)
    DUP IF BEGIN 1 DPL +! OVER C@ UPPER
       [CHAR] 0 - DUP 10 16 WITHIN OR DUP
       16 > 7 AND - DUP 0 BASE @ WITHIN WHILE
       SWAP >R 2SWAP BASE @ * SWAP BASE @ UM* D+ ROT 1+
    R> 1- DUP 0= UNTIL EXIT THEN DROP THEN ;

Gary

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Gary Sprung (US & Canada) 1 800 55-FORTH
FORTH, Inc. +1 310 372-8493
111 N. Sepulveda Blvd., Suite 300 Fax: +1 310 318-7130
Manhattan Beach, CA 90266
http://www.forth.com
"Forth-based products and Services for real-time
applications since 1973."
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Received on Wed Dec 13 2000 - 11:03:27 PST


Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!

This archive was generated 09-Feb-2012. Archive updated nightly.