FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » counting the digits in a number, exponential format problem
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: counting the digits in a number, exponential format problem [message #171001 is a reply to message #171000] Tue, 14 December 2010 18:50 Go to previous messageGo to previous message
mhandersen is currently offline  mhandersen
Messages: 5
Registered: December 2010
Karma:
Junior Member
certainly at some level PHP must know the difference between a string
and a float, but you can't a define a variable yourself as such. all i
was saying is that strlen() takes a variable, type of that variable
cannot be declared. i understand that strlen is intended for use with
'strings' but it also works for floats up to E-4 after which it breaks
down... all i am wondering is why???

i tried the strlen(sprintf("0.03%f",$mynum)) suggestion (and several
iterations of it) but no luck. i am not sure where PHP makes the
decision on whether or not to convert to a decimal but that doesn't
appear to help.

@Jerry: i totally agree with you that PHP must convert a numeric value
passed to strlen() to a string at some point. what i do not understand
though is why it makes a difference whether the numeric is 1E-4 or
1E-5. it is like that single order of magnitude drastically changes
the logic/conversion process of the numeric to a string and causes the
answer to not, as you say, 'be what i want'.

it is just not consistent at all. imho a function like strlen() should
pick one way of handling a type of input and do it consistently, not
vary its approach depending on the size of a value passed to it...
especially when it is a weakly typed language.

it appears as though PHP might use something similar to the Linux
function strtod(3) to do its string to float conversions. however, the
man page:
http://linux.die.net/man/3/strtod
does not shed any light on my problem.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: width measurements?
Next Topic: cheap, discount nike air max shoes, paypal payment, free shipping
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 29 17:14:57 GMT 2024

Total time taken to generate the page: 0.04268 seconds