tamas varhegyi

15 Reputation

One Badge

11 years, 75 days

MaplePrimes Activity


These are replies submitted by

@Carl Love 

Hi Carl,

Your solution was exactly what I needed, which was the ability to use a function which accepts a variable size real number.  That it converts real numbers in any format to the simplest string format simplifies my procedures considerably.  It rejects leading zeroes but leaves the extra trailing zeroes unchanged which is fine.

 FloatString:= (x::float)-> sprintf("%.*f", -op(2,x), x);
real_num:=0.248e-4;
FloatString(real_num);
 FloatString(00015670.0141000);
x::float -> sprintf("%.*f", -op(2, x), x)
                           0.0000248
                          "0.0000248"
                        "15670.0141000"

I really appreciate your help,
Tamas Varhegyi

 

@dharr 

Your suggestion lead me in the right direction, all what what missing the ability to use a function which accepts a variable size real number.  Carl Love 12079 in the next response wrote a function which does what I need :

 FloatString:= (x::float)-> sprintf("%.*f", -op(2,x), x);
real_num:=0.248e-4;
FloatString(real_num);
 FloatString(00015670.0141000);
x::float -> sprintf("%.*f", -op(2, x), x)
                           0.0000248
                          "0.0000248"
                        "15670.0141000"

Once again, I really appreciate your help,
Tamas Varhegyi

Page 1 of 1