Sign in to follow this  
Followers 0
monkey

Extract integer portion of floating point

6 posts in this topic

I have a SLC 500 and am trying to calculate (on the fly) positions for a stepper card. The position step values are as high as 2627948 which must be divided into a 'thousands' part (2627) and a 'ones' part (948) for use with the stepper card command words. To do this, I want to divide the large number by 1000 (2627.948) and then extract the integer portion of the number. I have tried to move the floating point number into an integer register but it rounds the number as it moves into the integer register.

Share this post


Link to post
Share on other sites
I think after a division, the resgister S14 is the non-rounded integer part and S:13 is the remainder (modulous) or maybe its the otherway around.

Share this post


Link to post
Share on other sites
I just read your other thread on the same topic. I don't know but it may make a difference if you put 1000 into an N-file and use that for the division. What are you using as the destination for the DIV instruction? It should not be S:14 You say it sometimes works. What do you mean? Edited by Spedley

Share this post


Link to post
Share on other sites
Divide by 1000 then subtract .5 then move to an integer. this gives whole no. Then subtract that value from the orginal floating point and multi by 1000.

Share this post


Link to post
Share on other sites
Spedly, When I said it worked sometimes it was because I was trying many different combinations of DIV sometimes with Integers for the source and sometimes with floating points. (the math register is NOT used when dealing with floating points) Guest, Thanks very much for the simple solution! You da man!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0