a (operator) b
The actual rules are relatively simple:
1) If both a and b are integers, the result is an integer.
2) For -, *, **, /, and \: Strings are evaluated as an integer or float, as
appropriate.
3) For +: If the first operand is a string, then string concatenation is
indicated; otherwise Rule 2 applies.
The practical result is that if you want to force a string to be a number,
prefix it with "0+":
$print "3.5" + "4.0"
3.54.0
$print 0 + "3.5" + "4.0"
7.5
If you want to force a string, prefix the expression with "":
$print 3.5 + 4.0
7.5
$print "" + 3.5 + 4.0
3.54..0
If you want to coerce a float to an integer, use \ (like Math.floor in
JavaScript) or %0 (even-value rounding, like Math.round)
$print 13.5 \ 3
4
$print (13.5 / 3) %0 + 1
5
Note that %n with n > 0 is used with a float to generate a string with a
given precision:
$print 13.5%2 + " A"
13.50 A
and %n with n < 0 is used to go into scientific notation as a string:
$print 13.5%-2 + " A"
1.4E+1 A
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users