Solved

How convert integer to float?

Posted on 1998-07-14
3
661 Views
Last Modified: 2013-12-03
I need assembly language to convert a 32 bit integer to a 32 bit float. My integer should always be consider positive and a fraction of 1 and right justified to the 6th digit beyond decimal point. For example:

integer     =      float
0           =      .000000
1           =      .000001
3872        =      .003872
987654      =      .987654

Also, if possible (not necessary for pts) can you explain the asm fpu instructions that are used to do such things.
0
Comment
Question by:RobertM041397
  • 3
3 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 400 total points
ID: 1410147
answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1410148
SRCINT DD 123456 ; Source value to convert to float. 1.23456.
DSTFLT REAL4 ?    ; Destination value to receive result.
DIVISOR  REAL4 1000000. ; Used to divide integer value to make fractional

   *    *   *

FILD SRCINT  ; load the source integer and convert to float.
FDIV DIVISOR ; Divide by divisor.
FSTP  DSTFLT ; Store the result and pop from floating point stack.

0
 
LVL 22

Expert Comment

by:nietod
ID: 1410149
FILD converts an integer to floating point and places it on the top of the floating point stack.  It can handle a 16 bit, 32 bit, or 64 bit integer.  This takes 3 clock cycles.
FDIV Divides the floating point value on the top of the stack by a specified floating point value.  this takes about 39 clock cycles.
FSTP stores the floating point value that is on the top of the stack and then removes it from the stack.  This takes 2 clock sycles.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now