Solved

How convert integer to float?

Posted on 1998-07-14
3
684 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

632 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