jason switzer (via RT) wrote: > # New Ticket Created by "jason switzer" > # Please include the string: [perl #59222] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=59222 > > > > This patch adds radix notation (:\d<...>) to the string-to-number conversion > routine Perl6Str::get_number. The tests haven't been written and > incorporated to test specifically the string conversion but the spectest > suite passes as of r31354 (parrot) and r22313 (t/spec). Cordination with > moritz_ will take place to determine the location and the extent of the > tests that will be created.
The tests should go into t/spec/S02-literals/radix.t if they aren't there yet. > Not all radix constructs are supported yet (in the works). Currently does > not support nested notation, such as :10<12*23**3> or functional forms such > as :10('1234'). If such things are to be supported in string-to-number conversions (is that specced? where?), it should really take the way through the grammar. In the end the user could change what he considers a number by modifying the grammar. Also note that these expressions could grow arbitrarily complex. > Index: perl6str.pmc > =================================================================== > --- perl6str.pmc (revision 31353) > +++ perl6str.pmc (working copy) > @@ -23,6 +23,58 @@ > #include <ctype.h> > #include <math.h> > > +FLOATVAL parse_number(const char** start, const char* stop, FLOATVAL radix) { > + FLOATVAL number = 0.0; > + //continue until the end or until we've hit a non-digit > + while (*start < stop && isxdigit((unsigned char)**start)) { Your usage of isxdigit() makes me wonder - will that work for bases > 16? Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/