Skip to main content
7 of 8
deleted 1 character in body
Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36

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

Jörg Hülsermann
  • 13.3k
  • 3
  • 15
  • 36