In SX Microcontrollers, SX/B Compiler and SX-Key Tool, VelocitąPaola wrote: You can still do everything in SX/B and decimal without having to think about it too much... just replicate the equation in single steps using parenthetical order of operations, followed by "computer order of operations" (i.e. left to right). They made it pretty easy by putting everything in parentheses though. You might need to utilize a couple temporary word variables to get to the final value. [code] rhLin = soRh ** 26542 tmpW1 = soRh ** 3468 tmpW2 = soRh ** 3468 tmpW1 = tmpW1 * tmpW2 tmpW1 = tmpW1 + 50 tmpW1 = tmpW1 / 100 rhLin = rhLin - tmpW1 rhLin = rhLin - 40 [/code] The above equation can be further reduced to save memory space by eliminating the tmpW2 variable: [code] rhLin = soRh ** 26542 tmpW1 = soRh ** 3468 soRh = soRh ** 3468 tmpW1 = tmpW1 * soRh tmpW1 = tmpW1 + 50 tmpW1 = tmpW1 / 100 rhLin = rhLin - tmpW1 rhLin = rhLin - 40 [/code] You don't need a complete understanding of binary to understand what they're doing (except for the multiply high operator, maybe). The main thing is to remember that the SX (and in turn, the BS2) can only do integer math. In order to achieve mathematical operations such as multiplying by a decimal, they first multiply one of the multiplicands by a factor of ten, or however much it takes to make the decimal a whole number. The result is later divided by that same factor. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=272864#m272865 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2008 (http://www.dotNetBB.com)