Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How convert integer to float?

Posted on 1998-07-14
3
Medium Priority
?
694 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 1600 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Integration Management Part 2

824 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