Tuesday, December 26, 2023

HP15C: A Corrected Floor Function by Werner

HP15C: A Corrected Floor Function by Werner



A Corrected Floor Function



On November 25, 2023, I posted floor and ceiling functions for the HP 15C, DM42, and HP 27S calculators.  I also posted the code on the Museum of HP Calculators (MoHPC).


Werner informed me that the floor code was inaccurate for x=-0.5.   In fact, the code is inaccurate for all x values from -1 to 0.  


The corrected code that Werner presented, by permission, on the MoHPC forum is:


Key Code : Key


__, 43, 44 : INT

42, _4, 25:  x<> I

__, 43, 36:  LST x

__, 42, 44:  FRAC

43, 30, _2:  TEST (x<0?)

42, _5, 25:  DSE I   (decreases I, always skips)

__, __, 16:  CHS  (nop)

__, __, 33:  R↓

42, _4, 25:  x<>I


This code works for all real values.   


For the ceiling function, use the identity:   ceil(x) = -floor(-x).  


   

MoHPC thread:  

https://www.hpmuseum.org/forum/thread-20766-post-182065.html#pid182065


Eddie


All original content copyright, © 2011-2023.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author. 


TI 30Xa Algorithms: Fundamental Horizontal Circle Calculations

  TI 30Xa Algorithms: Fundamental Horizontal Circle Calculations Introduction and Formulas Given the following: r = radi...