Skip to main content
added 132 characters in body
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36

PHP, 2623 Bytes

<?=-~log10(abs($argn?:1));

Try it online!Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use onelog10 gives back INF which is interpreted as false

The better way is to calculatereplace $argn with $argn?:1 +3 Bytes

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

+2 Bytes for string comparision $argn<"0"

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

PHP, 26 Bytes

<?=-~log10(abs($argn?:1));

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

PHP, 23 Bytes

<?=-~log10(abs($argn));

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input log10 gives back INF which is interpreted as false

The better way is to replace $argn with $argn?:1 +3 Bytes

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

+2 Bytes for string comparision $argn<"0"

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

deleted 1 character in body
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36

PHP, 2726 Bytes

<?=strlen($argn)=-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 28 Bytes

<?=log10~log10(abs($argn?:1))+1^0;;

Try it online!Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 28 Bytes

<?=log10(abs($argn?:1))+1^0;

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

PHP, 26 Bytes

<?=-~log10(abs($argn?:1));

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

deleted 20 characters in body
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 28 Bytes

<?=log10(abs($argn?:1))+1^0;

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 29 Bytes

<?=strlen($argn)-($argn<"0");

string length minus boolean string is lower then string "0"

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

PHP, 28 Bytes

<?=log10(abs($argn?:1))+1^0;

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 29 Bytes

<?=strlen($argn)-($argn<"0");

string length minus boolean string is lower then string "0"

Try it online!

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

PHP, 27 Bytes

<?=strlen($argn)-($argn<0);

string length minus boolean is lower then zero

Try it online!

PHP, 28 Bytes

<?=log10(abs($argn?:1))+1^0;

Try it online!

log of base 10 of the absolute value plus one cast to int

for zero as input use one to calculate

PHP, 32 Bytes

<?=preg_match_all("#\d#",$argn);

Try it online!

Regex count all digits

35 Bytes

<?=strlen($argn)-strspn($argn,"-");

Try it online!

string length minus count -

strspn

deleted 93 characters in body
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36
Loading
added 886 characters in body
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36
Loading
Rollback to Revision 1
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36
Loading
added 244 characters in body
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36
Loading
Source Link
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36
Loading