you can use the C static lib, just use Import.
Code: Select all
Structure mapm
*m_apm_data.c
m_apm_id.l
m_apm_refcount.l
m_apm_malloclength.l
m_apm_datalength.l
m_apm_exponent.l
m_apm_sign.l
EndStructure
ImportC "libc.lib"
; needed for the following symbols
; __mb_cur_max.l
; _pctype
EndImport
ImportC "mapm.lib"
*MM_Zero
*MM_One
*MM_Two
*MM_Three
*MM_Four
*MM_Five
*MM_Ten
*MM_PI
*MM_HALF_PI
*MM_2_PI
*MM_E
*MM_LOG_E_BASE_10
*MM_LOG_10_BASE_E
*MM_LOG_2_BASE_E
*MM_LOG_3_BASE_E
m_apm_init()
m_apm_free(*n.mapm)
m_apm_free_all_mem()
m_apm_trim_mem_usage()
m_apm_set_string(*n.mapm,sn.s)
m_apm_set_long(*mp.mapm, long.l)
m_apm_set_double(*mp.mapm, dbl.d)
m_apm_to_string(buffer.s, dplaces.l, *n.mapm)
m_apm_to_fixpt_string(buffer.s, dplaces.l, *n.mapm)
m_apm_to_fixpt_stringex(buffer.s, dplaces.l, *n.mapm, radix.c, separator_char.c, separator_count.l)
; example use
; m_apm_to_fixpt_stringex(s,20,*m,'.',',',5)
m_apm_to_fixpt_stringexp(dplaces.l, *n.mapm, radix.c, separator_char.c, separator_count.l)
; example use
; al.l=m_apm_to_fixpt_stringexp(100,*m,'.',',',5)
; s=PeekS(al)
; FreeMemory(al)
m_apm_to_integer_string(buffer.s, *n.mapm)
m_apm_absolute_value(*r.mapm, *n.mapm)
m_apm_negate(*r.mapm, *n.mapm)
m_apm_copy(*r.mapm, *n.mapm)
m_apm_round(*r.mapm, decimal_places.l, *n.mapm)
m_apm_compare.l(*x.mapm, *y.mapm)
m_apm_sign.l(*x.mapm)
m_apm_exponent.l(*x.mapm)
m_apm_significant_digits.l(*x.mapm)
m_apm_is_integer.l(*x.mapm)
m_apm_is_even.l(*x.mapm)
m_apm_is_odd.l(*x.mapm)
m_apm_gcd(*result.mapm, *x.mapm, *y.mapm)
m_apm_lcm(*result.mapm, *x.mapm, *y.mapm)
m_apm_add(*result.mapm, *x.mapm, *y.mapm)
m_apm_subtract(*result.mapm, *x.mapm, *y.mapm)
m_apm_multiply(*result.mapm, *x.mapm, *y.mapm)
m_apm_divide(*result.mapm, dplaces.l, *x.mapm, *y.mapm)
m_apm_integer_divide(*result.mapm, *x.mapm, *y.mapm)
m_apm_integer_div_rem(*quot.mapm, *rem.mapm, *x.mapm, *y.mapm)
m_apm_reciprocal(*result.mapm, dplaces.l, *x.mapm)
m_apm_factorial(*result.mapm, *x.mapm)
m_apm_floor(*result.mapm, *x.mapm)
m_apm_ceil(*result.mapm, *x.mapm)
m_apm_get_random(*result.mapm)
m_apm_set_random_seed(s.s)
m_apm_sqrt(*result.mapm, dplaces.l, *x.mapm)
m_apm_cbrt(*result.mapm, dplaces.l, *x.mapm)
m_apm_log(*result.mapm, dplaces.l, *x.mapm)
m_apm_log10(*result.mapm, dplaces.l, *x.mapm)
m_apm_exp(*result.mapm, dplaces.l, *x.mapm)
m_apm_pow(*result.mapm, dplaces.l, *x.mapm, *y.mapm)
m_apm_integer_pow(*result.mapm, dplaces.l, *x.mapm, y.l)
m_apm_integer_pow_nr(*result.mapm, *x.mapm, y.l)
m_apm_sin_cos(*sin.mapm, *cos.mapm, dplaces.l, *x.mapm)
m_apm_sin(*result.mapm, dplaces.l, *x.mapm)
m_apm_cos(*result.mapm, dplaces.l, *x.mapm)
m_apm_tan(*result.mapm, dplaces.l, *x.mapm)
m_apm_arcsin(*result.mapm, dplaces.l, *x.mapm)
m_apm_arccos(*result.mapm, dplaces.l, *x.mapm)
m_apm_arctan(*result.mapm, dplaces.l, *x.mapm)
m_apm_arctan2(*result.mapm, dplaces.l, *x.mapm, *y.mapm)
m_apm_sinh(*result.mapm, dplaces.l, *x.mapm)
m_apm_cosh(*result.mapm, dplaces.l, *x.mapm)
m_apm_tanh(*result.mapm, dplaces.l, *x.mapm)
m_apm_arcsinh(*result.mapm, dplaces.l, *x.mapm)
m_apm_arccosh(*result.mapm, dplaces.l, *x.mapm)
m_apm_arctanh(*result.mapm, dplaces.l, *x.mapm)
EndImport
OpenConsole()
*n.mapm
*m.mapm
*k.mapm
*n=m_apm_init()
*m=m_apm_init()
*k=m_apm_init()
s.s
;examples to assign values to an mp number
;m_apm_set_string(*n,"1") ;from string
;m_apm_set_long(*n,123) ;from long
;m_apm_set_double(*n,3.0) ;from double
;m_apm_copy(*m,*n) ;copy n to m
PrintN("Factorial of 20")
m_apm_set_long(*n,20)
m_apm_factorial(*k, *n)
al.l=m_apm_to_fixpt_stringexp(10,*k,'.',',',5)
s=PeekS(al)
FreeMemory(al) ;free the memory
PrintN(s)
;-- another way
s=Space(512) ;make sure there's enough memory allocated for convertion to string
m_apm_to_integer_string(s,*k)
PrintN(s)
;-- yet another way
s=Space(512)
m_apm_to_fixpt_stringex(s, 20, *k, '.', ',', 5)
PrintN(s)
;-- one more way
s=Space(512)
m_apm_to_string(s, 20, *k)
PrintN(s)
Print("Press RETURN to end ")
Input()
m_apm_free(*k)
m_apm_free(*m)
m_apm_free(*n)
CloseConsole()