Sign in to follow this  
Followers 0
TConnolly

[PLC Sample Code] - TRUNCATE IEEE754 FLOAT

2 posts in this topic

File Name: TRUNCATE IEEE754 FLOAT File Submitter: Alaric File Submitted: 7 Feb 2008 File Category: PLC Sample Code Sometimes is necessary to truncate (remove the fraction) or round a floating point number that is outside the range of -32678 to +32767 - making it impossible to use a MOV to an integer to make the conversion. This is a program I worte that shows how to perform a truncation directly on the floating point number by copyng the 32 bit pattern of the float and then determining which bits of the mantissa to keep and clearing all the rest. It includes three subroutines two of which show two different methods of truncating the float and a third which rounds the float to the nearest whole float. An understanding of the IEEE-754 float format is helpful in understanding how this program works but its not necessary to use it. Click here to download this file
1 person likes this

Share this post


Link to post
Share on other sites
On 7/2/2008 at 11:22 PM, TConnolly said:

File Name: TRUNCATE IEEE754 FLOAT File Submitter: Alaric File Submitted: 7 Feb 2008 File Category: PLC Sample Code Sometimes is necessary to truncate (remove the fraction) or round a floating point number that is outside the range of -32678 to +32767 - making it impossible to use a MOV to an integer to make the conversion. This is a program I worte that shows how to perform a truncation directly on the floating point number by copyng the 32 bit pattern of the float and then determining which bits of the mantissa to keep and clearing all the rest. It includes three subroutines two of which show two different methods of truncating the float and a third which rounds the float to the nearest whole float. An understanding of the IEEE-754 float format is helpful in understanding how this program works but its not necessary to use it. Click here to download this file

no file :-(

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