2

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?

halirutan
  • 112,764
  • 7
  • 263
  • 474
Eduardo
  • 123
  • 4

1 Answers1

5

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" *)
halirutan
  • 112,764
  • 7
  • 263
  • 474
  • 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.

    – Eduardo Feb 12 '13 at 16:19