code: def num_digits(n, base=10):
      """Return the number of digits needed to express n in give base.
  
      Examples
      ========
  
      >>> from sympy.core.intfunc import num_digits
      >>> num_digits(10)
      2
      >>> num_digits(10, 2)  # 1010 -> 4 digits
      4
      >>> num_digits(-100, 16)  # -64 -> 2 digits
      2
  
  
      Parameters
      ==========
  
      n: integer
          The number whose digits are counted.
  
      b: integer
          The base in which digits are computed.
  
      See Also
      ========
      sympy.ntheory.digits.digits, sympy.ntheory.digits.count_digits
      """
      if base < 0:
          raise ValueError("base must be int greater than 1")
      if not n:
          return 1
      e, t = integer_log(abs(n), base)
      return 1 + e
  
file_path: sympy/sympy/core/intfunc.py
imports: import math
  import sys
  from functools import lru_cache
  from .sympify import sympify
  from .singleton import S
  from sympy.external.gmpy import gcd, lcm, sqrt, iroot, bit_scan1, gcdext
  from sympy.utilities.misc import as_int, filldedent
label_desc: Use image node_id 1 for calling a global function with example usage: num_digits(n, base) and returns: unknown, int