2
$\begingroup$

I'm using Mathematica to create some images and labeling them after a simple calculation done previously. As the name of the file depends on the result, I want to show it with no decimal separator (because the "." can be a program as I'll use these images later on LabView). I'm using the following code:

ang = NumberForm[N[frac], {5, 2}]

where the result has 5 precise digits and 2 digits to the right of the decimal. Then, I'm doing angle = ang*100, but I still get the decimal marker but no number after it. How can I get rid of this?

$\endgroup$

1 Answer 1

5
$\begingroup$

Question: When you want to use this in the file name, why don't you use another character as NumberPoint?

ToString[NumberForm[N[8/3], {5, 2}, NumberPoint -> "_"]]

(* "2_67" *)

This can easily be included into a file name without problems.

To answer your question I have to start again with another question: Is there a special reason why you don't multiply by 100 and just round the result? (if you don't want it as String just remove the first function)

IntegerString[Round[N[8/3]*100]]

(* "267" *)
$\endgroup$
1
  • $\begingroup$ Thank you, that's what I was looking for. Using _ as a decimal separator is a great suggestion and the Round[] solution is what I wanted. $\endgroup$
    – Eduardo
    Feb 12, 2013 at 16:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.