[PD] float parsing

Hans-Christoph Steiner hans at eds.org
Fri Dec 29 00:46:16 CET 2006


On Dec 28, 2006, at 12:03 AM, Mathieu Bouchard wrote:

> On Wed, 27 Dec 2006, Miller Puckette wrote:
>
>> Dunno which is should be, but the 'c' language doesn't
>> allow unary '+' in front of numerical literals... so I
>> followed that lead.
>
> I don't know which C language you are talking about. Try compiling  
> the following program with options -ansi -pedantic-errors:
>
> #if + +1
> int main (void) {
>   int foo[+ +1] = { + + + + + + + + + + +1 };
>   return foo[0];
> }
> #endif
>
> This demonstrates that unary + works in front of numerical literal,  
> both in the main language and in the preprocessor. I don't know of  
> a way to test whether the last + before the 1 is actually  
> considered part of the literal or not. However, both scanf() and  
> strtod() consider + as part of a float literal (was there ever a  
> time that they didn't? really?).

What would be the advantages/disadvantages of either way?  My  
intuition says that  +1 should be a symbol, perhaps because it is  
rare to write positive numbers in math with a leading +.

Maybe the errant newbie might be confused when +1 turns out to be a  
symbol.  But if Pd starts removed + signs upon save, then that could  
also be annoying.

.hc


>
>  _ _ __ ___ _____ ________ _____________ _____________________ ...
> | Mathieu Bouchard - tél:+1.514.383.3801 - http://artengine.ca/matju
> | Freelance Digital Arts Engineer, Montréal QC  
> Canada_______________________________________________
> PD-list at iem.at mailing list
> UNSUBSCRIBE and account-management -> http://lists.puredata.info/ 
> listinfo/pd-list


------------------------------------------------------------------------

As we enjoy great advantages from inventions of others, we should be  
glad of an opportunity to serve others by any invention of ours; and  
this we should do freely and generously.         - Benjamin Franklin






More information about the Pd-list mailing list