class_docstr: Context for multiprecision arithmetic with a global precision.
class_docstr_tok: ["Context","for","multiprecision","arithmetic","with","a","global","precision","."]
docstr: Negates the number *x*, giving a floating-point result, optionally
  using a custom precision and rounding mode.
  
  See the documentation of :func:`~mpmath.fadd` for a detailed description
  of how to specify precision and rounding.
  
  **Examples**
  
  An mpmath number is returned::
  
      >>> from mpmath import *
      >>> mp.dps = 15; mp.pretty = False
      >>> fneg(2.5)
      mpf('-2.5')
      >>> fneg(-5+2j)
      mpc(real='5.0', imag='-2.0')
  
  Precise control over rounding is possible::
  
      >>> x = fadd(2, 1e-100, exact=True)
      >>> fneg(x)
      mpf('-2.0')
      >>> fneg(x, rounding='f')
      mpf('-2.0000000000000004')
  
  Negating with and without roundoff::
  
      >>> n = 200000000000000000000001
      >>> print(int(-mpf(n)))
      -200000000000000016777216
      >>> print(int(fneg(n)))
      -200000000000000016777216
      >>> print(int(fneg(n, prec=log(n,2)+1)))
      -200000000000000000000001
      >>> print(int(fneg(n, dps=log(n,10)+1)))
      -200000000000000000000001
      >>> print(int(fneg(n, prec=inf)))
      -200000000000000000000001
      >>> print(int(fneg(n, dps=inf)))
      -200000000000000000000001
      >>> print(int(fneg(n, exact=True)))
      -200000000000000000000001
docstr_tok: ["Negates","the","number","*","x","*",",","giving","a","floating-point","result",",","optionally","using","a","custom","precision","and","rounding","mode",".","See","the","documentation","of",":","func",":","`","~mpmath.fadd","`","for","a","detailed","description","of","how","to","specify","precision","and","rounding",".","*","*","Examples","*","*","An","mpmath","number","is","returned",":",":",">",">",">","from","mpmath","import","*",">",">",">","mp.dps","=","15",";","mp.pretty","=","False",">",">",">","fneg","(","2.5",")","mpf","(","'-2.5","'",")",">",">",">","fneg","(","-5+2j",")","mpc","(","real=","'","5.0","'",",","imag='-2.0","'",")","Precise","control","over","rounding","is","possible",":",":",">",">",">","x","=","fadd","(","2",",","1e-100",",","exact=True",")",">",">",">","fneg","(","x",")","mpf","(","'-2.0","'",")",">",">",">","fneg","(","x",",","rounding=","'","f","'",")","mpf","(","'-2.0000000000000004","'",")","Negating","with","and","without","roundoff",":",":",">",">",">","n","=","200000000000000000000001",">",">",">","print","(","int","(","-mpf","(","n",")",")",")","-200000000000000016777216",">",">",">","print","(","int","(","fneg","(","n",")",")",")","-200000000000000016777216",">",">",">","print","(","int","(","fneg","(","n",",","prec=log","(","n,2",")","+1",")",")",")","-200000000000000000000001",">",">",">","print","(","int","(","fneg","(","n",",","dps=log","(","n,10",")","+1",")",")",")","-200000000000000000000001",">",">",">","print","(","int","(","fneg","(","n",",","prec=inf",")",")",")","-200000000000000000000001",">",">",">","print","(","int","(","fneg","(","n",",","dps=inf",")",")",")","-200000000000000000000001",">",">",">","print","(","int","(","fneg","(","n",",","exact=True",")",")",")","-200000000000000000000001"]
code: def fneg(ctx, x, **kwargs):
      """
      Negates the number *x*, giving a floating-point result, optionally
      using a custom precision and rounding mode.
  
      See the documentation of :func:`~mpmath.fadd` for a detailed description
      of how to specify precision and rounding.
  
      **Examples**
  
      An mpmath number is returned::
  
          >>> from mpmath import *
          >>> mp.dps = 15; mp.pretty = False
          >>> fneg(2.5)
          mpf('-2.5')
          >>> fneg(-5+2j)
          mpc(real='5.0', imag='-2.0')
  
      Precise control over rounding is possible::
  
          >>> x = fadd(2, 1e-100, exact=True)
          >>> fneg(x)
          mpf('-2.0')
          >>> fneg(x, rounding='f')
          mpf('-2.0000000000000004')
  
      Negating with and without roundoff::
  
          >>> n = 200000000000000000000001
          >>> print(int(-mpf(n)))
          -200000000000000016777216
          >>> print(int(fneg(n)))
          -200000000000000016777216
          >>> print(int(fneg(n, prec=log(n,2)+1)))
          -200000000000000000000001
          >>> print(int(fneg(n, dps=log(n,10)+1)))
          -200000000000000000000001
          >>> print(int(fneg(n, prec=inf)))
          -200000000000000000000001
          >>> print(int(fneg(n, dps=inf)))
          -200000000000000000000001
          >>> print(int(fneg(n, exact=True)))
          -200000000000000000000001
  
      """
      prec, rounding = ctx._parse_prec(kwargs)
      x = ctx.convert(x)
      if hasattr(x, "_mpf_"):
          return ctx.make_mpf(mpf_neg(x._mpf_, prec, rounding))
      if hasattr(x, "_mpc_"):
          return ctx.make_mpc(mpc_neg(x._mpc_, prec, rounding))
      raise ValueError(
          "Arguments need to be mpf or mpc compatible numbers"
      )
  
imports: import functools
  import re
  from .ctx_base import StandardBaseContext
  from .libmp.backend import basestring, BACKEND
  from .None import libmp
  from .libmp import MPZ, MPZ_ZERO, MPZ_ONE, int_types, repr_dps, round_floor, round_ceiling, dps_to_prec, round_nearest, prec_to_dps, ComplexResult, to_pickable, from_pickable, normalize, from_int, from_float, from_str, to_int, to_float, to_str, from_rational, from_man_exp, fone, fzero, finf, fninf, fnan, mpf_abs, mpf_pos, mpf_neg, mpf_add, mpf_sub, mpf_mul, mpf_mul_int, mpf_div, mpf_rdiv_int, mpf_pow_int, mpf_mod, mpf_eq, mpf_cmp, mpf_lt, mpf_gt, mpf_le, mpf_ge, mpf_hash, mpf_rand, mpf_sum, bitcount, to_fixed, mpc_to_str, mpc_to_complex, mpc_hash, mpc_pos, mpc_is_nonzero, mpc_neg, mpc_conjugate, mpc_abs, mpc_add, mpc_add_mpf, mpc_sub, mpc_sub_mpf, mpc_mul, mpc_mul_mpf, mpc_mul_int, mpc_div, mpc_div_mpf, mpc_pow, mpc_pow_mpf, mpc_pow_int, mpc_mpf_div, mpf_pow, mpf_pi, mpf_degree, mpf_e, mpf_phi, mpf_ln2, mpf_ln10, mpf_euler, mpf_catalan, mpf_apery, mpf_khinchin, mpf_glaisher, mpf_twinprime, mpf_mertens, int_types
  from .None import function_docs
  from .None import rational
  from .ctx_mp_python import _mpf, _mpc, mpnumeric
label_desc: Use image node_id 37 for calling the MPContext obj's underlying member method code with example usage: obj.fneg(ctx, x) and returns: ctx, ctx