g | x | w | all
Bytes Lang Time Link
051Rust240813T180010Zbzr
018JavaScript Node.js240812T021839Zl4m2
004UiuaSBCS240811T185155ZEurope20
002Thunno 2230610T133915ZThe Thon
nanFig221007T213243ZSeggan
014FALSE221007T162121ZJoe
011K ngn/k221007T142701Zoeuf
002Japt221006T122102ZShaggy
002MathGolf221006T120131ZKevin Cr
017K ngn/k220523T094922Zoeuf
101Batch220522T224107ZYouserna
031Desmos220522T184949ZnaffetS
013Factor + projecteuler.common220522T110615Zchunes
002Risky210709T130817Zxigoi
002Vyxal210709T121213Zemanresu
007Julia210413T170146ZMarcMush
020PowerShell Core210413T003032ZJulian
002Arn s210412T222728ZZippyMag
039Whispers v2210411T152847Zcaird co
020V vim210411T152058ZRazetime
015BRASCA210203T104955ZSjoerdPe
015GNU AWK201220T212417ZPedro Ma
004APL Dyalog Extended201220T131041ZKamila S
005GolfScript201020T001944Z2014MELO
004Bound201019T223639ZHoofedEa
015Excel VBA170929T034839ZTaylor R
013Pari/GP170520T042131Zalephalp
006TIBasic TI84 Plus CE170518T012004Zpizzapan
005Jelly170519T140321Zuser6318
023JavaScript170519T044209ZPaul
022awk170518T202227Zsteve
012Ruby170516T200950ZValue In
037brainfuck170518T183202ZBusiness
023Axiom170518T173707Zuser5898
095Fortran 95 gfortran170517T142707Zwafflest
1118Taxi170516T205154ZEngineer
138Swift170518T115458ZCaleb Kl
024Java170518T110519ZOlivier
038C170518T065853ZKhaled.K
9312Perl 5170518T050928ZChris
076C++170516T235222ZTas
006MATL170516T211227ZLuis Men
026Lua170517T215009ZFelipe N
038TSQL170517T180046ZWORNG AL
015Bash170517T170403Zmarcosm
043C170517T162238Zjdt
078GNU Make170517T162225Zeush77
005Chaincode170517T161352ZLinnea G
024C#170517T161204ZTheLetha
028C#170517T145250ZTheLetha
022REXX 22 Bytes170517T135904Ztheblitz
nanBrainFlak170517T122320ZErik the
023PHP170516T195537ZJör
023JavaScript ES6170517T092949ZDom Hast
002Braingolf170517T090003ZMayube
010Alice170517T085813ZLeo
004MATL170517T085736ZLuis Men
018R170517T085248ZSven Hoh
024JavaScript ES6170516T195604ZShaggy
033C#170517T080018ZBojan B
001Brachylog170517T041033Zuser6213
9110Perl 5170517T042012Zuser6213
007J170517T035839ZConor O&
004Pyth170517T032438Zclapp
020Bean170517T004821ZPatrick
003dc170516T205546ZDigital
002RProgN 2170516T225242ZATaco
035Befunge170516T212951Zbwillsh
020Ruby170516T212146Zmarmelad
005Japt170516T210514ZLuke
063BrainFlak170516T203321ZDJMcMayh
016Alice170516T201032ZMartin E
013Mathematica170516T193849ZMartin E
030Fourier170516T194248ZBeta Dec
005CJam170516T194043ZBusiness
00205AB1E170516T194013ZRiley
022Python 2170516T193811Ztotallyh
002Jelly170516T193902ZJonathan
00205AB1E170516T193854ZMagic Oc
024PowerShell170516T193539Zcolsw
002Retina170516T193328ZMartin E

Rust, 51 bytes

fn main(){let f=|n:i128|n.abs().to_string().len();}

Attempt This Online!

JavaScript (Node.js), 18 bytes

f=x=>x&&-~f(x/10n)

Try it online!

JavaScript (Node.js), 21 bytes

x=>(x+[-x]).length>>1

Try it online!

19 if input as string, but worse than Johan Karlsson's answer then

UiuaSBCS, 4 bytes

⧻°⋕⌵

Try it here!

Explanation

⧻°⋕⌵
   ⌵ absolute value
 °⋕  convert to string
⧻    length

Thunno 2, 2 bytes

Al

Attempt This Online!

length of the Absolute value of the implicit input.

Fig, \$2\log_{256}(96)\approx\$ 1.646 bytes

LA

Try it online!

LA
L  # Length of
 A # The absolute value of the input

FALSE, 14 bytes

^45=[1+^~][]#.

Try it online!

Explanation: If first character is '-' (ascii code 45), then push -1. Else push 0. Add 1 to number on stack until EOF character is reached.

K (ngn/k), 11 bytes

{#($x)^"-"}

Try it online!

Easy.

Explanation:

{#($x)^"-"}    Main function. Takes x as input
  ($x)         x as string
      ^"-"     Without string literal "-" (Remove negative symbol)
 #             Length

Japt, 2 bytes

ìl

Try it

ìl     :Implicit input of integer
ì      :Convert to digit array
 l     :Length

MathGolf, 2 bytes

±£

Input as integers.

Try it online.

I'm actually surprised builtin £ works on integers. I was expecting I would need an explicit cast, since that's the case with a lot of MathGolf's builtins.

Explanation:

±   # Get the absolute value of the (implicit) input-integer
 £  # Pop and get the length of this integer
    # (after which the entire stack is output implicitly as result)

K (ngn/k), 17 bytes

{#$$[x<0;x*-1;x]}

Try it online!

Can't handle big numbers correctly, e.g. 33107638153846291829. Still decent though.

Batch, 101 bytes

@set/pi=
@set o=-1&if %i:~,1%==- set o=-2
:l
@set/ao+=1&if %i%. neq . set i=%i:~,-1%&goto:l
@echo %o%

89 bytes

@set/pi=
@if %i% lss 0 set/ai=-%i%
:l
@set/ao+=1&if %i% gtr 9 set/ai/=10&goto:l
@echo %o%

Only works for 32-bit numbers.

Desmos, 31 bytes

g=abs(a)
f(a)=floor(log(g+0^g))

Try it on Desmos!

Factor + project-euler.common, 13 bytes

number-length

Try it online!

Risky, 2 bytes

!?}*

Try it online!

! length
?     input
}   base convert
*     10

Vyxal, 2 bytes

ȧL

Try it Online!

 L # Length of...
ȧ  # Absolute value of...
   # Implicit input

Julia, 7 bytes

ndigits

Try it online!

PowerShell Core, 20 bytes

$args|% *m '-'|% Le*

Try it online!

Arn -s, 2 bytes

.|

Try it!

Take absolute value, -s takes size. Implicit casting.

Whispers v2, 39 bytes

> Input
>> |1|
>> "2"
>> #3
>> Output 4

Try it online!

Boring answer. Get input, absolute value, convert to string, return length.

V (vim), 20 bytes

:s/-
C<C-r>=strlen(<C-r>")
<esc>

Try it online!

Remove minuses(if any), cut the line, and get its length.

Not sure if I need the <esc> at the end.

BRASCA, 15 bytes

iM:45S=[xx0]x!n

Try it online!

Explanation

i                - Turn the ascii characters 0-9 to numbers
 M:45S=[  0]     - Move the bottom of the stack to the front and check if it's a minus
        xx       - If so: remove the minus
            x    - Remove any excess items on the stack
             !n  - Print the length as a number

GNU AWK, 18 17 15 bytes

$1=gsub(/\w/,1)

Substitutes every number character (except for the minus sign) alphanumeric character of the input for another character (here, the number 1), and assigns the number of substitutions to the output.

Thanks for cnamejj and manatwork for helping me saving some bytes!

Try it online!

AWK, 17 bytes

$1=gsub(/[^-]/,1)

This is a previous answer, that should work on any Awk version, not only GNU's.

Try it online!

APL (Dyalog Extended), 4 bytes

≢∘⍕|

Try it online!

GolfScript, 5 bytes

"-"-,

Try it online!

"-"-    # Remove all "-" in the input
    ,   # Get the length of the string

Bound, 4 bytes

ib_,

Explanation:

i # Get user input
b # Separate each digit of the top element into individual elements
_ # Put the total number of elements onto the stack
, # Remove all but the top element from the stack

Bound then prints the stack at the end of execution, so you can then see the result.

Try it online!

Excel VBA, 15 Bytes

Anonymous VBE immediate window function that takes input from [A1] and outputs to the VBE immediate window

?[Len(Abs(A1))]

Pari/GP, 13 bytes

n->#digits(n)

Try it online!

TI-Basic (TI-84 Plus CE, OS 5.2+), 6 bytes

length(toString(abs(Ans

TI-Basic is a tokenized language; length( and toString( are two bytes each.

Ans is used as implicit input; the last (only) line's value is implicitly returned.

Pretty simple, takes the absolute value to get rid of a minus sign, converts to string, returns the length of the string.

A 6-byte mathematical approach that doesn't work for 0:

1+log(abs(Ans

Jelly, 5 bytes

A‘l⁵Ċ

Try it online!

JavaScript, 23 bytes

x=>`${x<0?-x:x}`.length

awk, 22 bytes

$1=length($1<0?-$1:$1)

Try it online!

All test cases

Ruby, 15 11+1 = 16 12 bytes

Uses the -n flag.

p~/$/-~/\d/

Try it online!

Explanation

                  # -n flag gets one line of input implicitly
p                 # Print
 ~/$/             # Position of end of line (aka string length) in input
     -            # minus
      ~/\d/       # Position of first digit (1 if negative number, 0 otherwise)

brainfuck, 37 bytes

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

Output is by byte value.

Try it online!

Explanation

-[+>+[+<]>+]>->  Constant for 45 (from esolangs wiki)
,                Read a byte of input
[-<->]           Subtract that byte from 45
<[>+>]           If the result is nonzero then increment a cell and move to the right
                 (0 means it was a minus; so not counted)
,[<+>,]          Read a byte and increment the cell to its left until EOF is reached
<.               Print the cell that was being incremented

Axiom, 23 Bytes

f(x)==#(abs(x)::String)

Fortran 95 (gfortran), 121 96 95 bytes

program c
character b
call get_command_argument(1,b,length=i)
print*,i-index(b,'-')
end program

Explanation:
Subtracts the index of the '-' sign from the length of the argument.
Arrays start at 1 in Fortran, and index() returns 0 if symbol not found.

Edit: Switched to implicit integer "i", also consolidated argument getter.

Edit: -1 byte thanks to @Tsathoggua

Taxi, 1118 bytes

1 is waiting at Starchild Numerology.Go to Post Office:w 1 l 1 r 1 l.Pickup a passenger going to Chop Suey.Go to Chop Suey:n 1 r 1 l 4 r 1 l.Pickup a passenger going to Crime Lab.'-' is waiting at Writer's Depot.Go to Writer's Depot:n 1 l 3 l.Pickup a passenger going to Crime Lab.Go to Crime Lab:n 1 r 2 r 2 l.Switch to plan "n" if no one is waiting.-1 is waiting at Starchild Numerology.[n]0 is waiting at Starchild Numerology.Go to Starchild Numerology:s 1 r 1 l 1 l 2 l.Pickup a passenger going to Cyclone.Pickup a passenger going to Addition Alley.Go to Cyclone:e 1 l 2 r.[r]Pickup a passenger going to Cyclone.Pickup a passenger going to Addition Alley.Go to Zoom Zoom:n.Go to Addition Alley:w 1 l 1 r.Pickup a passenger going to Addition Alley.Go to Chop Suey:n 1 r 2 r.Switch to plan "f" if no one is waiting.Pickup a passenger going to Sunny Skies Park.Go to Sunny Skies Park:n 1 l 3 l 1 l.Go to Cyclone:n 1 l.Switch to plan "r".[f]Go to Addition Alley:n 1 l 2 l.Pickup a passenger going to The Babelfishery.Go to The Babelfishery:n 1 r 1 r.Pickup a passenger going to Post Office.Go to Post Office:n 1 l 1 r.

Try it online!

Ungolfed:

1 is waiting at Starchild Numerology.
Go to Post Office: west 1st left 1st right 1st left.
Pickup a passenger going to Chop Suey.
Go to Chop Suey: north 1st right 1st left 4th right 1st left.
Pickup a passenger going to Crime Lab.
'-' is waiting at Writer's Depot.
Go to Writer's Depot: north 1st left 3rd left.
Pickup a passenger going to Crime Lab.
Go to Crime Lab: north 1st right 2nd right 2nd left.
Switch to plan "n" if no one is waiting.
-1 is waiting at Starchild Numerology.
[n]
0 is waiting at Starchild Numerology.
Go to Starchild Numerology: south 1st right 1st left 1st left 2nd left.
Pickup a passenger going to Cyclone.
Pickup a passenger going to Addition Alley.
Go to Cyclone: east 1st left 2nd right.
[r]
Pickup a passenger going to Cyclone.
Pickup a passenger going to Addition Alley.
Go to Zoom Zoom: north.
Go to Addition Alley: west 1st left 1st right.
Pickup a passenger going to Addition Alley.
Go to Chop Suey: north 1st right 2nd right.
Switch to plan "f" if no one is waiting.
Pickup a passenger going to Sunny Skies Park.
Go to Sunny Skies Park: north 1st left 3rd left 1st left.
Go to Cyclone: north 1st left.
Switch to plan "r".
[f]
Go to Addition Alley: north 1st left 2nd left.
Pickup a passenger going to The Babelfishery.
Go to The Babelfishery: north 1st right 1st right.
Pickup a passenger going to Post Office.
Go to Post Office: north 1st left 1st right.

Explanation:

Pickup the input and split it into individual characters
Pickup the value 1.
If the first character a hyphen, add -1. Otherwise, add 0.
Keep picking up characters and adding 1 until you're out.
Convert the running total to a string and print to stdout.

Swift, 138 bytes

You would think there would be an easier way to do this.

import Foundation;var d:(String)->Int={return $0.trimmingCharacters(in:CharacterSet(charactersIn:"0123456789").inverted).characters.count}

You can try it here

Un-golfed:

import Foundation // Import the Foundation module

var d:(String)->Int={ // Create a closure that takes in a String and returns an Int

    return // Return the following

    $0.trimmingCharacters(in:  // Removes all characters in the following CharacterSet

        CharacterSet(charactersIn:"0123456789").inverted // Create a CharacterSet with all characters that are not digits

    ).characters.count // Get the length of the resulting String
}

Java, 30 24 bytes

i->(""+i.abs()).length()

Assumes i is a BigInteger. Also, the type is contextualized, so no imports are required, as shown in the test code.

Test

// No imports
class Pcg120897 {
  public static void main(String[] args) {
    java.util.function.ToIntFunction<java.math.BigInteger> f =
        // No full class declaration past here
        i->(""+i.abs()).length()
        // No full class declaration before here
      ;
    System.out.println(f.applyAsInt(new java.math.BigInteger("-1267650600228229401496703205376"))); // -(2^100)
    System.out.println(f.applyAsInt(new java.math.BigInteger("1267650600228229401496703205376"))); // (2^100)
  }
}

Saves

C, 71 38 bytes

Try Online

f(char*t){return*t?(*t>'-')+f(t+1):0;}

Perl 5, 9 bytes + 3 for -F flag=12 bytes

say@F-/-/

Run like perl -F -E 'say@F-/-/'. Takes a single number from stdin without a trailing newline. Can add the -l flag at the cost of an extra byte if you would rather have it accept a trailing newline.

The -F flag auto splits stdin into the array @F. In scalar context, @F evaluates to the length of the array, which is the number of characters in $_ (which comes from stdin). /-/ in a numerical context evaluates to 1 if $_ has a minus sign in it or 0 if $_ does not have a minus sign in it, so @F-/-/ evaluates to the number of non-minus sign characters (i.e. the number of digit characters) read from stdin.

C++, 80 76 bytes

#include<string>
int main(int,char**c){printf("%d",strlen(c[1])-(*c[1]<46));}

Prints the length of the argument, minuses 1 if the first character is a minus because bool guarantees conversion to 1 if true or 0 if false

MATL, 6 bytes

nGU0<-

Try it online!

Explanation

n     % Implicitly input a string. Push its length
G     % Push input again
U     % Convert to number (floating-point double). Although integers with absolute
      % value exceeding 2^53 cannot be represented exactly, the sign is correct
0<    % Is it negative?
-     % Subtract. Implicitly display

Lua, 26 bytes

Replaces all occurrences of '-' with the empty string '' and get length with #.

print(#(...):gsub('-',''))

Try it online!

T-SQL, 38 bytes

CREATE PROC l @ BIGINT AS PRINT LEN(@)

Usage:

EXECUTE l @ = 9999999999

Bash, 15 bytes

wc -L<<<${1//-}

Try it online!

Deletes - from input as array, and otputs length of longest line (wc -c returns one char more than length)

C, 43 bytes

f(char*s){printf("%d",strlen(s)-(*s==45));}

Try it online

GNU Make, 78 bytes

Imperative style:

$(eval T=$1)$(foreach D,$(shell seq 9),$(eval T=$(subst $D,? ,$T)))$(words $T)

Functional style, 113 bytes:

$(eval 2?=$(shell seq 9))$(if $2,$(call $0,$(subst $(word 1,$2),? ,$1),$(wordlist 2,$(words $2),$2)),$(words $1))

Pure Make, 83 bytes:

$(eval T=$1)$(foreach D,0 1 2 3 4 5 6 7 8 9,$(eval T=$(subst $D,? ,$T)))$(words $T)

Chaincode, 5 bytes

pqL_+

Explanation

pqL_+ print(
    +   succ(
   _      floor(
  L        log_10(
pq           abs(
               input())))))

C#, 24 bytes

n=>$"{n>0?n:-n}".Length;

Inspired from @DomHastings answer.

C#, 28 bytes

s=>s.Replace("-","").Length;

REXX 22 Bytes

arg "-" a
say length(a)

Explanation: There is no distinction in Rexx between numbers and strings. The action you perform is what defines the type. The "typing" applies just to that action and can change at any time.

So, here the number (say -20) is treated as a string. The "arg" instruction (short for parse arg) tells Rexx to search for the first "-" and then put everything after it in the variable "a". If "-" is not found then everything goes in "a".

Try it here

REXX functions and instructions

Brain-Flak, 48 + 3 ( -a) = 51 bytes

({}[((((()()()()())){}{})){}{}]){(<><>)}{}([]<>)

Try it online!

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

JavaScript (ES6), 23 bytes

s=>`${s>0?s:-s}`.length

Different approach to Shaggy's answer.

Braingolf, 2 bytes

dl

Explaination:

dl
    Implicit input from command-line args to stack
d   Pop last item from stack, split it into digits, and push each digit to the stack
 l  Push length of stack to the end of the stack
    Implicit output of last item on stack

Alice, 10 bytes (non-competing)

 /d/
O@IHc

Try it online!

This is a non-competing solution, because at the time this challenge was posted the command c was bugged in the official (and only :D) interpreter. Martin Ender fixed it in the meanwhile, so this now works.

Explanation

The instruction pointer passes through the two mirrors (/) multiple times, so it may be a bit difficult to follow. I'll try to explain it as clearly as I can, using cardinal directions (e.g. N is up, SW is down to the left...). I'll call /1 the leftmost mirror, and /2 the rightmost one.

Command    Direction    Comment
               E        Execution starts from the upper-left corner going right
   /1        E → SE     Passing through the mirror changes direction and switches
                        to ordinal mode (string operations)
   I        SE → NE     Push the input string to the stack, then bounce against
                        the bottom of the code
   /2       NE → S      Back to cardinal mode (numeric operations)
   H           S        Pop n, push abs(n). Execution wraps from bottom to top
   /2        S → SE     Ordinal mode again
   c        SE → NW     Pop s, push each char of s separatedly. Bounce against
                        the bottom right corner
   /2       NW → W      Cardinal mode
   d           W        Push the depth of the stack (which is now equal to 
                        the number of characters in abs(input))
   /1     W → NW → SW   Pass through the mirror, then bounce agains the top
   O        SW → NE     Output the result, then bounce on the bottom left corner
   /1       NE → S      Last mirror, I promise
   @           S        Terminate execution

MATL, 4 bytes

47>s

Inspired by Martin's Retina answer: count how many characters have code point exceeding 47 (this excludes the minus sign).

Try it online!

R, 18 bytes

nchar(abs(scan()))

JavaScript (ES6), 27 26 25 24 bytes

Takes input as a string.

s=>s.match(/\d/g).length

C#, 33 bytes

i=>Math.Abs(i).ToString().Length;

Brachylog, 1 byte

l

Try it online!

Another builtin solution, but this one has the shortest name (unless someone finds a language which does this task in zero bytes). This should work in both Brachylog 1 and Brachylog 2.

This is a function submission (the TIO link contains a command-line argument that causes the interpreter to run an individual function rather than a whole program), partly because otherwise we'd have to spend bytes on output, partly because Brachylog's syntax for negative numbers is somewhat unusual and making this program a function resolves any potential arguments about input syntax.

It's often bothered me that most of Brachylog's builtins treat negative numbers like positive ones, but that fact ended up coming in handy here. I guess there are tradeoffs involved with every golfing language.

Perl 5, 9 + 1 = 10 bytes

$_=y/-//c

Try it online!

Run with -p (1 byte penalty).

Explanation

$_=y/-//c
            {implicit from -p: for each line of input}
   y/ //    In {the input}, replace
        c     everything except
     -        '-'
$_=         Store number of replacements back in $_
            {implicit from -p: output $_}

We treat the input as a string in order to handle numbers outside the 64-bit range. One interesting trick here is that we don't have to specify what we're replacing the nonhyphens with; we can still count the number of replacements that occur.

The TIO link uses -l in order to let us run the program on multiple data without the newlines between them interfering. If the program only has to run once, we can do without it, so long as there's no final newline on the input.

J, 7 bytes

#@":@**

Try it online!

All the solutions I came up with:

0>.@>.10^.>:@(**)
[:#10&#.inv
#@-.&'-'
#@":@**

The first one is math, the second is base conversion, the third takes a string as input, and the shortest takes a number.

The current solution looks like this:

              ┌─ # 
        ┌─ @ ─┴─ ":
  ┌─ @ ─┴─ *       
──┴─ *             

The parent root is a hook between the upper tine and the lower tine. The lower tine (*) is a monad that calculates magnitude. The upper tine is a composition:

         ┌─ # 
   ┌─ @ ─┴─ ":
@ ─┴─ * 

This composes the upper tine (another composition) with *, in this case, a dyad. This is the dyad for multiplication. In the last tine:

   ┌─ # 
@ ─┴─ ":

This calculates format (":) then length (#).

In English form, this is "multiply x times the sign of x, then convert this to a string, then take the length of this string". Basically, abs.toString.length.

Pyth, 4 bytes

l`.a

Try it online!

All test cases

Bean, 20 bytes

Hexdump:

00000000: 2650 80d3 d080 a05d 2080 0921 8181 0020  &P.ÓÐ. ] ..!... 
00000010: 8001 dc64                                ..Üd

JavaScript equivalent:

a.match(/\d/g).length;

Explanation:

Implicitly takes input as a decimal string in a and implicitly outputs the length of the match, which is all the decimal digits in the string. Returns 1 for input of 0.

See Demo.

Bean, 22 bytes

Hexdump:

00000000: 2aa0 1f26 4ccc d3a0 8043 53a0 802d 2043  * .&LÌÓ .CS .- C
00000010: 9125 398b 253a                           .%9.%:

JavaScript equivalent:

with(Math)((log10(abs(A))^0)+1);

Explanation:

Implicitly takes input as a decimal integer in A, takes the absolute value, then log-base-10, XORs with 0, then adds 1.

When A is 0, the returned value of log10() is -Infinity, and -Infinity ^ 0 is 0 in JavaScript, so the returned value for 0 is 1.

See Demo.

dc, 3

?Zp

Note that normally dc requires negative numbers to be given with _ instead of the more usual -. However, in this case, either may be used. If - is given, then dc treats this as a subtraction on an empty stack, throws dc: stack empty, and then continues with the rest of the number; Thus the result is no different.

Try it online.

?    # input
 Z   # measure length
  p  # print

RProgN 2, 2 bytes

âL

Try it online!

Simply gets the absolute value of the input, and counts the digits.

Befunge, 35 bytes

77*~`!1+:v
~0`#@    ># !#. #- #2_1+

Try it online!

77*~`!            add 49 to the stack and see if that is less than 50 (ascii for
                  '-') 
1+:v              if there is a -, don't count it. Add 1 so we don't
                  have a zero at the top of the stack. Move down.
># !#. #- #2_1+   move right and add one to the total. (Will remove later)
~0`#@             Loop back around and take an input and make sure it is not end of 
                  the string (-1, so we make sure it is > 0)
># !#. #- #2_1+   check to see if there was an input. If there was, add one to the 
                  total. If not, move left. Subtract 2 because we added 1 at two 
                  different locations. Print output and end program.

Ruby, 20 bytes

->a{a.abs.to_s.size}

Japt, 5 bytes

a s l

Try it online!

Explanation

 a s l
Ua s l
Ua     # take the absolute value of the input
   s   # and turn it into a string
     l # and return its length

Brain-Flak, 63 bytes

([({})]((((()()()()())){}{})){}{})((){[()](<{}>)}{})([{}][]<>)

Try it online!

This is 62 bytes of code and +1 byte for the -a flag.

I tried two other approaches, but unfortunately both of them were longer:

([]<({}[((((()()()()())){}{})){}{}]<>)((){[()](<{}>)}{})>)({}[{}])

([]<>)<>({}<>)((((([][]())){}{})){}{}[{}])((){[()](<{}>)}{})([{}]{})

This should be a very short answer. In fact, if we didn't have to support negative numbers, we could just do:

([]<>)

But we have to compare the first input with 45 (ASCII -) first, which is most of the byte count of this answer.

An arithmetic solution might be shorter.

Alice, 16 bytes

//; 'q<)e
o!@i -

Try it online!

Explanation

Finding a half-decent layout for this was quite tricky. I'm still not super happy with it because of the spaces, the < and the ;, but this is the best I could do for now.

String length is one of those very common built-ins that doesn't exist in Alice, because its input is a string and its output is an integer (and all Alice commands are strictly integers to integer or strings to strings). We can measure a string's length by writing it to the tape in Ordinal mode and then finding its end in Cardinal mode.

/      Reflect to SE. Switch to Ordinal. While in Ordinal mode, the IP will bounce
       diagonally up and down through the code.
!      Store an implicit empty string on the tape, does nothing.
;      Discard an implicit empty string, does nothing.
i      Read all input as a string.
'-     Push "-".
<      Set the horizontal component of the IP's direction to west, so we're bouncing
       back now.
-      Remove substring. This deletes the minus sign if it exists.
'i     Push "i".
;      Discard it again.
!      Store the input, minus a potential minus sign, on the tape.
/      Reflect to W. Switch to Cardinal. The IP immediately wraps to the
       last column.
e)     Search the tape to the right for a -1, which will be found at the end
       of the string we stored there.
<      Does nothing.
q      Push the tape head's position, which is equal to the string length.
'<sp>  Push " ".
;      Discard it again.
/      Reflect to NW. Switch to Ordinal. The IP immediately bounces off
       the top boundary to move SW instead.
o      Implicitly convert the string length to a string and print it.
       IP bounces off the bottom left corner, moves back NE.
/      Reflect to S. Switch to Cardinal.
!      Store an implicit 0 on the tape, irrelevant.
       The IP wraps back to the first line.
/      Reflect to NE. Switch to Ordinal. The IP immediately bounces off
       the top boundary to move SE instead.
@      Terminate the program.

I also tried taking care of the minus sign in Cardinal mode with H (absolute value), but the additional mode switch always ended up being more expensive in my attempts.

Mathematica, 13 bytes

IntegerLength

There's a built-in... returns 0 for 0.

Fourier, 30 bytes

I~S<0{1}{-2*S~S}S{0}{S^~S}SL^o

Try it on FourIDE!

Fourier doesn't have strings, so it uses logs instead. Bytes are wasted on supporting zero and negative numbers.

CJam, 5 bytes

q'--,

String based.

Try it online!

9 bytes for a purely math-based solution:

riz)AmLm]

Or another 5 with base conversion:

riAb,

05AB1E, 2 bytes

Äg

Try it online! or Try All Tests!

Ä  # Absolute value
 g # Length

Python 2, 31 22 bytes

-9 bytes thanks to Rod.

lambda i:len(`abs(i)`)

Try it online!

Jelly, 2 bytes

DL

Try it online!

This does literally what was asked:

DL - Main link number n         e.g. -45
D  - convert to a decimal list       [-4,-5]
 L - get the length                  2

05AB1E, 2 bytes

þg

Try it online!

   # Implicit input [a]...
þ  # Only the digits in [a]...
 g # length of [a]...
   # Implicit output.

PowerShell, 24 Bytes

"$args"-replace'-'|% Le*

casts the "absolute" value of the input args to a string and gets the 'length' property of it.

1 byte shorter than "".Length

until someone finds a better way to get the abs of a number in PS this is probably as short as it will get.

Retina, 2 bytes

\d

Try it online!

Retina doesn't really know what numbers are, so the input is treated as a string and we simply count the digit characters.