Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How convert integer to float?

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

662 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