Solved

How convert integer to float?

Posted on 1998-07-14
3
669 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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