diff options
author | Alex Merry <dev@randomguy3.me.uk> | 2013-08-27 15:25:26 +0100 |
---|---|---|
committer | Alex Merry <dev@randomguy3.me.uk> | 2013-08-27 15:25:26 +0100 |
commit | ad6c6441f4482e12722ae17283dd7a470e3fdcde (patch) | |
tree | 81fcf3677139906df6c9932a143d972f01713906 /tikzit/src/common/Graph.m | |
parent | ea86afc07d645c1ba79800fed7c005d444d60f80 (diff) |
Make sure we never output numbers in scientific notation
Converting NSNumber to a string raises the possibility of outputing a
number like 2.2e-8, as it essentially uses the %g format specifier.
This then cannot be parsed.
Since there is no built-in specifier for outputing floats with variable
precision (ie: removing any trailing zeros), I cooked up a function to
do just that.
Currently set the maximum precision at 4dp (our normal grid layout only
makes use of 2dp).
Diffstat (limited to 'tikzit/src/common/Graph.m')
-rw-r--r-- | tikzit/src/common/Graph.m | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tikzit/src/common/Graph.m b/tikzit/src/common/Graph.m index 258ece4..2d07ccc 100644 --- a/tikzit/src/common/Graph.m +++ b/tikzit/src/common/Graph.m @@ -720,8 +720,8 @@ [code appendFormat:@"\t\t\\node %@ (%d) at (%@, %@) {%@};\n", [[n data] tikzList], i, - [NSNumber numberWithFloat:[n point].x], - [NSNumber numberWithFloat:[n point].y], + formatFloat([n point].x, 4), + formatFloat([n point].y, 4), [n label] ]; i++; |