saruans

real to integer number

7 posts in this topic

Hello,

Could somebody give for me advice how need seperate real number to integer? for example I have in D10 real number 10,9 for me need to do integer number 10 and 9. The real number seperate to integer I am using this LADDER line, attached picture. In D90 I got 10, But how to isolate the number of decimal places,I can not think of.
Please help for me

RealToInteger.jpg

Share this post


Link to post
Share on other sites

Subtract them... you get 0.9

Guess what the next step is... 

Share this post


Link to post
Share on other sites
8 hours ago, panic mode said:

Subtract them... you get 0.9

Guess what the next step is... 

How subtract them? Have you in mind this below example

 

try.jpg

Edited by saruans

Share this post


Link to post
Share on other sites

note:

INT and REAL have different instructions and binary representation. 

 

you don't mention CPU type and i have not seen Mitsubishi in years but it should be something like:

1. convert REAL to INT (D10 to D90)

2. convert INT to REAL (D90 to D98)

3. subtract REAL from REAL (D98 from D10, result to D96)

4. multiply D96 by 10.0 (result to D94)

5. convert REAL to INT (D94 to D92).

 

your result is in D90 and D92

Share this post


Link to post
Share on other sites

How i can do this on mitsubishi fx-1n CPU which do not support INT instruction ??

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