static mpf_t getd() { mpf_t d = new mpf_t(); gmp_lib.mpf_init(d); char_ptr value = new char_ptr("1000000000000000000000000"); gmp_lib.mpf_set_str(d, value, 10); return(d); }
public void Add(string hastings) { var s = new char_ptr(hastings); mpf_t x = new mpf_t(); gmp_lib.mpf_init(x); gmp_lib.mpf_set_str(x, s, 10); gmp_lib.free(s); gmp_lib.mpf_div(x, x, d); gmp_lib.mpf_add(value, value, x); gmp_lib.mpf_clear(x); }
/// <summary> /// Return the string representation of the float. /// </summary> /// <returns>The string representation of the float.</returns> public override string ToString() { if (!_initialized) { return(null); } mpfr_exp_t exp = 0; char_ptr s_ptr = mpfr_lib.mpfr_get_str(char_ptr.Zero, ref exp, 10, 0, this, mpfr_lib.mpfr_get_default_rounding_mode()); string s = s_ptr.ToString(); gmp_lib.free(s_ptr); if (s.StartsWith("-", StringComparison.Ordinal)) { return("-0." + s.Substring(1) + "e" + exp.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } else { return("0." + s + "e" + exp.Value.ToString(System.Globalization.CultureInfo.InvariantCulture)); } }