Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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" *)
share|improve this answer
    
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 Goncalves Feb 12 '13 at 16:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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