## jmol-developers

 [Jmol-developers] Jmol math From: Bob Hanson - 2007-11-05 01:11:17 ```I've spent some time this weekend updating http://chemapps.stolaf.edu/jmol/docs/examples-11/new.htm and http://chemapps.stolaf.edu/jmol/docs/?ver=11.4#variables In particular, check out the documentation on variables. It is now much more extensive. While doing that I found some math bugs in Jmol -- mostly very esoteric stuff, but some possibly relevant business as well. Nico, Jmol 11.3.41 is ready to roll. I set up a test script that runs through every possible combination of operation in Jmol, checking the type of the result. You can see the output at http://chemapps.stolaf.edu/jmol/docs/misc/operations.txt Mostly what this shows is that the math works. I realize that the mixing of variable types is a rat's nest. I'm hoping that the description in the documentation is satisfactory, but I realize there is no simple solution to doing this right. Mostly we just have to have ways of doing what we imagine one might want to do and not have it so difficult that the above-average user can't figure it out. If anyone feels the rules should be different, now's the time to express that opinion, before these rules become part of Jmol 11.4. Rules I think ARE important: Adding something to a string should result in a string: x = "the number is " + y Adding a string to a number should do a natural conversion: x = 5.3 + "4.6" # x = 9.9 (Because we don't have explicit type conversions.) Simple integer math should stay integer; involving decimals should result in decimals. x = 5/2 # x = 2 x = 5/2.0 # x = 2.5 Adding things to arrays should result in an array. x = array(1,"red",2,"blue") y = x + 3 # y = array(1,"red",2,"blue",3) y = {0 1 1} + x # y = array({0 1 1},1,"red",2,"blue") Doing AND, OR, or NOT on a bitset should result in a bitset: x = {atomno<30} y = {atomno>20} z = x AND y # z = {atomno > 20 and atomno < 30} I've introduced some implicit conversions that should be useful but might be not so obvious. Take a look at the documentation; I can add more examples if we need them. Bob -- Robert M. Hanson Professor of Chemistry St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 ```