develooper Front page | perl.perl5.porters | Postings from December 2000

Re: strtoul (was Re: [PATCH] Fcntl constants speedup)

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
December 20, 2000 07:27
Subject:
Re: strtoul (was Re: [PATCH] Fcntl constants speedup)
Message ID:
20001220152715.F12624@plum.flirble.org
On Wed, Dec 20, 2000 at 03:15:19PM +0000, Nick Ing-Simmons wrote:
> Nicholas Clark <nick@ccl4.org> writes:

> >I was thinking something like
> >
> >int son_looks_like_number (SV * sv, UV *value);
> >that returns flags about what it found out in the int, and the value in
> >*value if the pointer is non null, and the value doesn't overflow.
> >(flags include "minus", "erk we've overflowed the UV", "saw a decimal point"
> >"saw e notation" and "infinity" as now; the UV would return the abs value)
> 
> Apart from the name that is okay.

what, the politically correct child_of_looks_like_number()? would be better?
:-)
Sorry, meant to make it clear that I couldn't think of a real name
off the top of my , so used that as a placeholder.

> I would be tempted to make it return the bit-pattern rather than the abs
> value - but I assume you have your reasons.

The reasoning was that the calculation would be done as unsigned, so it
takes a bit more effort to return a bit pattern for a negative value
(and this is actually getting presumptuous about 2s complement.
How many platforms that aren't 2s complement does perl build on currently?)
And it may be that a large negative value is less than IV_MIN, but the
caller can use -(NV)value to set the NV slot without having to flip
the negative bit pattern back to positive first.

but it's not written yet, so this may not turn out to be useful.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About