g | x | w | all
Bytes Lang Time Link
022Tcl180610T231706Zsergiol
012Thing180612T072333ZWindmill
005Braingolf180611T105800ZMayube
002RProgN 2180611T085625ZATaco
002Japt180611T085419ZShaggy
00205AB1E180611T083447ZKevin Cr
022Python 2160906T101336ZErik the
025R160906T112035Zcia_rana
067Go160906T110827Zcia_rana
028Java 8160905T121744ZShaun Wi
025PowerShell140128T170722Zmicrobia
057C140128T174046ZJosh
004APL140130T031501ZGandalf
001GolfScript140126T153500ZDoorknob
030PHP140130T000358ZFlame
nan140128T231812Zshemerey
nanI'm trying to stay away from the simple string length functions140126T164631ZTyzoid
nan140128T170156Zdraegtun
019bash140128T200128Zuser1525
nan140128T194006Zbela
003GTB140128T160502ZTimtech
nan140128T153827Zplannapu
059C140128T145028ZOberon
025python 2140126T155449ZWasi
nan140128T132238Zglezmen
812Befunge98140126T170235ZFireFly
020JavaScript140126T162742ZBlue She
003Dc140126T163537Zmanatwor
nanPerl with lp 11 bytes140126T163126Znull
007k [7 chars]140126T162757Znyi

Tcl, 22 bytes

puts [string le $argv]

Try it online!

Thing, 12 bytes

idh\-=[tLe]L

Try it online!

How?

Gets input from command line arguments. If the first character of input is "-", push the length of the all but first items of the string and immediately end the program. Else, push the length of the string. Then implicitly print.

Does not work with multiline.

i push input
d duplicate
h first character of
\- push the character "-"
= if top two values are equal, push 1, if not, 0
    [ if top value is truthy (not [] or 0), go into the block. if not,  go past the end of the block. 
    t push the all but first items of the stack's top value (literally s[1:] in python)
    L length
    e end the program
    ] end loop
L length

Braingolf, 5 bytes

!s*dl

Try it online!

As with all the others, abs then len

RProgN 2, 2 bytes

âL

Gets the length of the Absolute Value of the input. Trivial.

Try it online!

Japt, 2 bytes

ìl

Try it

ì converts to a digit array and l gets the length.

05AB1E, 2 bytes

þg

Try it online or verify all test cases.

Explanation:

þ     # Take the digits of the input
 g    # And output the length

Python 2, 22 bytes

lambda a:len(`abs(a)`)

I actually built this myself, before seeing Wasi's answer! This is how I thought of it:

[Thinking ends]

R, 25 bytes

cat(nchar(scan("stdin")))

Go, 67 bytes

package main;import."fmt";func main(){s:="";Scan(&s);Print(len(s))}

Java 8, 29 28 bytes

i->(""+(i<0?-i:i)).length();

Ungolfed test program

public static void main(String[] args) {
    IntFunction<Integer> func = i -> ("" + (i < 0 ? -i : i)).length();

    System.out.println(func.apply(12345)); //5
}

PowerShell (25)

($n-replace"-",'').length

where $n is a number

C, 63 59 57 characters

It's slightly longer than the other C solution, but it works on arbitrarily large numbers (numbers with 2^32 - 1 digits rather than numbers up to 2^32 - 1).

EDIT: It's now shorter than the other C solution!

c;main(n){n-10?main(getchar(),c+=n>47):printf("%d\n",c);}

Note: if you call the program with exactly 9 arguments, it will fail. But why would you do that??

APL - 4 characters

ρ'n'

The first symbol, rho, checks the number of cells in an array, where one character of a string is equal to one cell.

GolfScript, 1 character

,

, means length...

Edit: You seem to have changed your question... please don't do that, but I still have a solution:

GolfScript, 12 7 characters (for multiline)

n%{,n}/

Thanks @Howard for reminding me about n to push newline and using separate strings instead of one, to save 5 chars ;)

Solutions that work with negative numbers:

GolfScript, 5 (for negative)

'-'-,

GolfScript, 11 (for multiline and negative)

n%{'-'-,n}/

PHP (30 chars)

echo $n<0?(strlen($n)-1):strlen($n)

(without php opening tags <?php & ?>)

Explanation

Pretty simple, ints can be interpreted as strings, therefore $n<0 has a minus-char that should be removed in the true-statement of the ternary operator. If its positive then we just count the length ;)

Ruby

$*.first.size

or

ARGV.first.size

I'm trying to stay away from the simple string length functions, but the BF solution basically does a count.

Pure math/Mathematica - 22 chars (for mathematica)

floor(log10(abs(n)))+1

Thanks to @plg for the correction when n is a power of 10. This invokes undefined behavior when n=0, but that case can be returned by a simple check.

PHP implementation of the above math solution - 34 chars

($n==0)?1:floor(log(abs($n),10))+1;

BrainF*ck - 54 characters

>>+[<+>++++++++++,----------]<-<++++++++[>++++++<-]>.

Perl

15 chars - no input or constraint checks

$_=()=$_=~/\d/g

48 chars - checks input & constraint

$_=/^-?(\d+)$/?($1<=10**9?length($1)."\n":$_):$_

NB. If the input ($_) is an integer (positive or negative) and comes under the constraint then it amends $_ to the number of digits. Otherwise it just leaves the input as is.

Usage example:

perl -ple '... insert above code...'

bash - 19 characters

Assuming input via standard input:

grep -o [0-9]|wc -l

Multi-line version - 48 characters:

while read L;do echo $L|grep -o [0-9]|wc -l;done

A DELPHI PROGRAM FOR CONSOLE

program P;
{$APPTYPE CONSOLE}
uses
  System.SysUtils;
var a: Integer;
begin
   readln(a);
   writeln(length(IntToStr(a)));
end.

GTB, 3

Assuming value is already stored:

l?_

To make user input:

`_l?_

Newline support with interactive input:

[`_~l?_]

R

The solution at 18 characters (identical in concept to the python solution of Wasi):

nchar(abs(scan()))

And the funnier one at 33 characters:

which(!abs(scan())%/%10^(1:9))[1]

C - 59 characters

main(k){scanf("%i",&k);printf("%i\n",(int)log10(abs(k))+1);}

python 2, 25

print len(`abs(input())`)

works for both positive and negative integers

Perl

s/\D//;$_=length

run as:

perl -ple 's/\D//;$_=length'

Befunge-98, 8 or 12 chars

Single number (actually counts input bytes ≥15 and prints count at EOF)
#.~f`+#@
Multiline support (same as above, but print count at byte <15 and reset counter)
#@~f`:2*j\.+

JavaScript, 20

alert((""+n).length)

Dc: 3 characters

?Zp

Sample run:

bash-4.2$ dc -e '?Zp' <<< '12346'
5

bash-4.2$ dc -e '?Zp' <<< '345'
3

Perl (with -lp) (11 bytes, counting lp)

$_=length

k [7 chars]

f:{#$x}

Example:

f 12346
5

f 456
3

Though only 2 characters (#$) are required to find the length of the input number.

#$123444
6

Explanation

convert the input to string.

$123456
"123456"

count the number of characters:

#$123456
6

Q equivalent of this code:

f:{count string x}
f 123456
6