monkey
Dec 22 2004, 01:13 PM
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.
Spedley
Dec 22 2004, 04:02 PM
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.
Spedley
Dec 22 2004, 04:06 PM
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?
Guest
Dec 23 2004, 09:37 AM
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.
monkey
Dec 23 2004, 10:43 AM
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!
Mickey
Dec 23 2004, 05:01 PM
[QUOTE]Guest,
Thanks very much for the simple solution!
You da man!
Thanks,
Not so easy, it took me three days to come up with that. As is sometimes the case
after a long day of working on something I stop and jump in my car to go home,
5 min. down the road it comes to me. Strange how that works for me.
Mickey
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here.