How to reduce the number of decimal places in a wave?

Hi everybody,
I would like to decrease the number of decimal places in a wave. Using the Table-->Digits menu, only the visualization is changed.
I would like to change the original data.

Thank you in advance!
This is not elegant, but you could multiply your numbers by the xth power of 10 (where x is the number of decimal places you want to end up with), then use ceil, floor, round or trunc, and finally divide the result by the original power of ten.

EDIT:

Here you go. There's probably an in-built function to do this but I couldn't find it. Hahaha - try finding the command help for WaveList for example. ;-)

function truncateDP(inValue,targetDP)
// targetDP is the number of decimal places we want
    Variable inValue, targetDP
    targetDP = round(targetDP)
    inValue = round(inValue * (10^targetDP)) / (10^targetDP)
    return inValue
end


To do a whole wave at once you'd just change the declaration of inValue from Variable to Wave in the code above, and maybe declare the whole thing as function/WAVE. In fact, since you're new:

function/WAVE truncateDP(inValue,targetDP)
// targetDP is the number of decimal places we want
    Wave inValue
    Variable targetDP
    targetDP = round(targetDP)
    inValue = round(inValue * (10^targetDP)) / (10^targetDP)
    return inValue
end


EDIT 2: Why on Earth do you want to do this?
Hi jdorsey!
Thank you for your quick reply!
You're right a built-in command or menu-item :-) would be great!
I need to reduce the number of decimal places because I have noise in the last digit of my data!
After I want to sort the wave according to another key-wave.

Thank you again!
I'm not a big fan of the concept of 'significant digits', and the way it is often taught. I don't think reducing the precision of your data is a good solution to deal with uncertainty or noise.

If you wish to minimize the impact of noise, I'd suggest you to use smoothing instead. If you want to report uncertainties, then add explicit error estimates or error bars.

While I'm only tangentially familiar with this subject, I think that the apparent lack of built-in truncation functionality in Igor is appropriate.
I don't see any advantage in reducing the significant figures in noisy data either, but I guess Christian understands his application better than we do...
741 wrote:
While I'm only tangentially familiar with this subject, I think that the apparent lack of built-in truncation functionality in Igor is appropriate.


In the area of displaying numbers in a panel or so, it is appropriate to round data. The sprintf modifiers don't round, they only cut off.
thomas_braun wrote:
In the area of displaying numbers in a panel or so, it is appropriate to round data. The sprintf modifiers don't round, they only cut off.


I'm not sure I follow exactly:
Printf "%.3g\r", 3.4567 => 3.46
Printf "%.3g\r", 3.4547 => 3.45


Looks like it's rounding, not truncating, to me. Sprintf gives the same results.