[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - problem with integer

problem with integer

Q&A's, tips, howto's

problem with integer

Postby Maurizio » Sat Dec 06, 2003 10:43 pm

Maurizio
 
Posts: 52
Joined: Mon Jul 28, 2003 3:06 pm
Location: Italy

Postby Lutz » Sat Dec 06, 2003 10:48 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Maurizio » Sun Dec 07, 2003 9:49 am

well, but "12a", as well "12xyz" should not be considered an integer !
regards
Maurizio
Maurizio
 
Posts: 52
Joined: Mon Jul 28, 2003 3:06 pm
Location: Italy

Postby HPW » Sun Dec 07, 2003 11:43 am

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby Lutz » Sun Dec 07, 2003 2:53 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Maurizio » Sun Dec 07, 2003 6:06 pm

Maurizio
 
Posts: 52
Joined: Mon Jul 28, 2003 3:06 pm
Location: Italy

Postby nigelbrown » Mon Dec 08, 2003 12:04 am

Keep in mind that regrading leading + or spaces with number?
a leading + is not valid
eg
> (number? "+12")
nil
> (number? "-12")
true
>

I also noticed that the definition of what (integer ) will accept is not
quite the same as strtoul as strtoul will accept leading spaces while
(integer ) will not (that leading spaces are not allowed is stated in the manual)
viz
> (number? " 12")
nil
> (integer " 12")
nil

Borland says of strtol regarding leading whitespace (strtoul uses same rules) :
...the characters must match this generic format:

[ws] [sn] [0] [x] [ddd]

where:

[ws] = optional whitespace
[sn] = optional sign (+ or -)
[0] = optional zero (0)
[x] = optional x or X

[ddd] = optional digits
...

Possibly for user input you may wish to accept leading spaces - but
perhaps you skip over this already.

Just a couple of points to bear in mind.
Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Mon Dec 08, 2003 1:37 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Thu Dec 11, 2003 9:23 pm

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Thu Dec 11, 2003 9:45 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Fri Dec 12, 2003 12:35 am

Further on (integer ) - it chokes aka "crashes" on too big a floating point
when used in the second sense of its definition
integer
syntax: (integer str [default-exp] )
syntax: (integer num [default-exp] )
viz
newLISP v7.3.17 Copyright (c) 2003 Lutz Mueller. All rights reserved.

> (integer 3.5)
3
> (integer 1e8)
100000000
> (integer 1.5e8)
150000000
> (integer 1e20)


Probably relates to "math exception handling" thread
http://www.alh.net/newlisp/phpbb/viewtopic.php?t=102

?unless the big number is infinity
Interestingly +INF converts to 0 with (integer ) viz

newLISP v7.3.17 Copyright (c) 2003 Lutz Mueller. All rights reserved.

> (float 3.5)
3.5
> (float 1e600)
+INF
> (setq infinity 1e600)
+INF
> (integer infinity)
0
> infinity
+INF
>

Apologies for stressing out newlisp with all these funny numbers.

Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Fri Dec 12, 2003 2:44 pm

>>
Apologies for stressing out newlisp with all these funny numbers.
>>

No apologies! this is exactly what is needed to bring newLISP forward. Your involvement has brought newLISP a big step forward during the last weeks. Thankyou for investing the time to find out all this.

In the upcoming 7.4.0 rc1 (release candidate 1), all floats will be truncated to the min/max integers when using 'integer' in its second syntax when converting floats. NaNs will still return 0.

In the first syntax, when converting from string it will still behave like before (using strtol() for conversion, this gives us conversion of hex and octal too).

About the '(abs (sqrt -1))' crash on Win32 on the other thread.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests

cron