Simple question, but I can't seem to find an answer. If I am trying to display a battery voltage, for example, a difference of a few decimal points can be very important. If I have this:
stringFromNumber(voltage) + 'V'
and voltage is 12.4, it will output 12V. This is no good. I could quite easily fix this by editing the resultant StyleKit, but I would have to do that every time I made a change, which would be a real pain. Does anyone have a solution?
I am working with the C# output, but the problem exists with both C# and Objective-C.
Relevant Code:
In PaintCode I have a Voltage String expression of stringFromNumber(voltage) + 'V'
which generates:
private void DrawGuage(float voltage) {
...
var voltageString = new NSString(Math.Round(voltage).ToString()) + "V";
...
I want PaintCode to generate the same, but without the Math.round
.
I found a way. It's a bit messy, but it works.
stringFromNumber(floor(voltage)) + (
frac(voltage) != 0 ? '.'+stringFromNumber(frac(voltage)*10) : ''
) + 'V'
Also, I got in touch with PaintCode support, and they said they would think about adding a better way of doing this in a future version, but had a temporary fix similar to mine :
stringFromNumber(round(number)) + "." + stringFromNumber(round(number * 100 % 100))