TConnolly Posted February 7, 2008 Report Posted February 7, 2008 TRUNCATE IEEE754 FLOAT View File 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. Submitter TConnolly Submitted 02/07/2008 Category PLC Sample Code 1
Koggaccio Posted February 5, 2018 Report Posted February 5, 2018 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now