NumericFormats

From Compost Wiki
Revision as of 19:46, 24 January 2018 by Noahj (talk | contribs) (added the ! character to the decimal point control)
Jump to navigation Jump to search

Numeric Formats

Multiplier (one per format, optional)

  • 1 through 9 appearing in the format string before the first : or ;. The value will be multiplied by the single digit integer multiplier first, before any other formatting is performed. If omitted, a 1 is assumed.

Sign Control (Use only one max. per format, optional)

  • ±: Plus sign shown for positive values, negative for negative values. Generally combined with ";+0.". The positive sign in this case is the "zero string" so it is output as a literal.
  • absent: No "sign character" will use only the default, show.
  • -: Show - for negative and a space for positive values.

Polarity Modification (use none, one or both in the same format, optional)

  • *: Multiply value times minus one. This is always executed second by ncPost, regardless of order in format string.
  • +: Show absolute value. This is always positive and always executed first by ncPost.

Digit Control

  • #: A digit, fixed if after the decimal, that will be suppressed if it is a leading or trailing zero.
  • 0: A fixed digit that cannot be suppressed. Leading and trailing zeros will be output.
  • b: A fixed digit that will output a blank in place of each leading and trailing zero.

Decimal Point Control

  • absent: No decimal point control character implies an integer value.
  • .: Show the decimal point (if there is a format character after the ".". #.# with the value 1.0000 will output 1., #. will output 1
  • ,: Conditional Decimal Point, show the decimal point only if there are trailing values. (version 11+ only) #,# with the value will output 1, #, will output 1
  • ^: Do not show the decimal point.
  • !: Force the decimal point always.

Zero Control (optional)

  • ;: You may add a ; to the end of a format. The text following the ; will be output for any value equal to zero. If omitted, default zero will be from the actual format, which may reduce to nothing in the case of ###,###.
  • Just to reiterate, the string that is input after the ";" is output literally, it does not obey any "rules." So #,#;I'm a little teapot, would output 1 for 1.0 and "I'm a little teapot" for 0.

Rounding Control (optional)

  • :: This character my be added, followed with a 1, 2, or 5. This is the value that the last digit in the format will be rounded to. If omitted, a 1 is assumed.

Some Examples are: {based on 21.34531}


#.#### pretty standard for modern controls {21.3453}
#,#### pretty standard for modern controls {21.3453}, {2.00} would be {2} (Works for .POST only, not .PST)
#.####;0 force zero to `0' {21.3453}
2#.#### multiply times 2 {42.6906}
#.####;0.:5 round to nearest .0005 {21.3455}
*#.####;0.:2 times minus one {-21.3454}
+*#.####;0.:5 absolute value, then times minus one (always negative) {-21.3455}
3+*#.### absolute value of three times the value, times minus 1 {-64.036}
00##.##0 stupid, `#'s have effect only when on the outside unless decimal has been suppressed, {0021.345}
0000.000 same effect as above {0021.345}
#00.0000# {21.34531}
##00^0000# stupid, formats without a visible decimal point may not have suppressible characters(`#') on both sides of the decimal and outside. The control has no way to figure out the real value. {2134531}
#^###0 standard fixed format,leading zero suppression, 1 equals 10000, 0.01 equals 100, {213453}
####^### Don't do this. Even if a ";0" is supplied, compost will complain. Include at least one fixed decimal, like #^##0
000^#### standard fixed format,trailing zero suppression, 1 equals 001, .01 equals 00001, {0213453}
# integer {21}


To use the new b correctly, it should be inside any # and outside any 0. ##b0.00b# {+b2.3453, the b represents a space}.

The standard convention is to list Multiplier first. Sign control second, Polarity modifiers third, followed by Digits and Decimal point control characters. Then comes special Zero control and Round control last. Following this simple convention will make it easier on everyone.

When using Number commands, especially in lathe, use Radius Number commands and format them times two. We will probably eliminate the Diameter Number commands at some point in the future.