Divide Result in decimal or float

Hi,
Here i am doing division calculation for two int values. 
payroll   occbeddays   result  
2168        2969           0
But i want the result as 0.73
How can i got this?
@temp_STATSCAL AVGPAYROLL is money datatype.
INSERT INTO @temp_STATSCAL (FACILITY,AVGPAYROLL)
SELECT r.FACILITY,
CASE WHEN s.OCCBEDDAYS >0 THEN
r.PAYROLL/s.OCCBEDDAYS
ELSE
0
END
FROM @temp_STATS s
CROSS JOIN @temp_REVENUE r WHERE r.FACILITY=s.FACILITY

You can use this code also
Select
Convert(decimal(10,2),(Convert(decimal,2168)/
Convert(decimal,2969)))
[Result]

Similar Messages

  • How I know when divide some number the results is decimal ?

    I am new programing in java, I looking for any instruction what tell me where I divide a number and the results is a decimal number like 2.5, 4.9, etc.

    > Excuse me, Mr_Evil, but I am a new programer, I try
    to use that instruction, but I don't get it. Do you
    have some example about that instruction. I
    appreciate your efforts for me.
    Thanks
    This is what Mr_Evil meant:double originalValue = 0.0d;
    for(int i = 0; i < 10; i++) {
      originalValue += 0.1d;
    // round originalValue to the closest (mathematical) integer
    double roundedValue = Math.rint(originalValue);
    System.out.println("Is the original value "+originalValue+
              " an integer? "+(originalValue == roundedValue));; )

  • Inconsistent results wrapping text using floats in CSS

    I have <div id="sidebar1"> that floats right, inside of
    <div id="mainContent"> which houses all the content. IE won't
    allow the text to extend (wrap) the entire width of <div
    id="mainContent"> once it is past or below <div
    id="sidebar1"> that floats right. Firefox allows it and displays
    correctly. I am using SPRY widgets in <div id="sidebar1">
    Below is the code...
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN" "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="
    http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    <title>Citecast Digital Signage</title>
    <link href="/CSS/twoColElsRtHdr.css" rel="stylesheet"
    type="text/css" />
    <!--[if IE]>
    <style type="text/css">
    /* place css fixes for all versions of IE in this conditional
    comment */
    .twoColElsRtHdr #sidebar1 { padding-top: 30px; }
    .twoColElsRtHdr #mainContent { zoom: 1; padding-top: 15px; }
    /* the above proprietary zoom property gives IE the hasLayout
    it needs to avoid several bugs */
    </style>
    <![endif]-->
    <script src="Scripts/AC_RunActiveContent.js"
    type="text/javascript"></script>
    <script src="SpryAssets/SpryMenuBar.js"
    type="text/javascript"></script>
    <script type="text/javascript"
    src="p7pm/p7popmenu.js"></script>
    <script src="SpryAssets/SpryAccordion.js"
    type="text/javascript"></script>
    <style type="text/css" media="screen">
    <!--
    @import url("p7pm/p7pmh7new.css");
    -->
    </style>
    <link href="SpryAssets/SpryAccordion.css" rel="stylesheet"
    type="text/css" />
    </head>
    <body class="twoColElsRtHdr"
    onload="P7_initPM(1,7,1,-20,10)">
    <div class="twoColElsRtHdr" id="container">
    <div id="header">
    </div>
    <!-- end #header -->
    <div id="container_margintop">
    <div id="menu">
    <!--#include virtual="/includes/citecastmenu-NEW.html"
    -->
    </div>
    <div id="sidebar1">
    <div id="Accordion1" class="Accordion" tabindex="0">
    <div class="AccordionPanel">
    <div class="AccordionPanelTab">Research shows digital
    signage is more memorable, less annoying than other
    media</div>
    <div class="AccordionPanelContent">
    <p><strong>Caveats to keep in mind
    ...</strong></p>
    <p>Like any research sponsored by a party with a
    vested interest in the outcome, these results need to be taken with
    a grain of salt. </p>
    <p> <a
    href="/Pages/articles-columns-news/researchShows...caveats to keep
    in mind.shtml">more ...</a> </p>
    </div>
    </div>
    <div class="AccordionPanel">
    <div class="AccordionPanelTab">Research shows digital
    signage is more memorable ... <strong>What does it all
    mean?</strong></div>
    <div class="AccordionPanelContent">
    <p>Some of the above results simply indicate how much
    time the respondents spend interacting with each type of media.
    </p>
    <p><a
    href="/Pages/articles-columns-news/researchShows...what does it all
    mean.shtml">More ...</a> </p>
    </div>
    </div>
    </div>
    <br />
    <br />
    <div align="center"><img
    src="/Images/clarkpowell-integrator-logo.png" alt="clark powell"
    width="214" height="69" /></div>
    <div align="center"><img src="/Images/cp 25yr
    seal.png" /></div>
    <br />
    <div align="center"><img
    src="/Images/princeton_logo_horiz.jpg" alt="princeton"
    /></div><br />
    <br />
    <!-- end #sidebar1 --></div>
    <div id="mainContent">
    <h1 align="center"> </h1>
    <h2 align="center">Turn Key Digital Signage</h2>
    <p align="center">
    <script type="text/javascript">
    AC_FL_RunContent( 'codebase','
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','wid th','344','height','400','title','Citecast
    digital signage
    example','src','/flash/home-tv-reflection','quality','high','pluginspage','
    http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movi e','/flash/home-tv-reflection'
    ); //end AC code
    </script>
    <noscript>
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0"
    width="344" height="400" title="Citecast digital signage
    example">
    <param name="movie" value="/flash/home-tv-reflection.swf"
    />
    <param name="quality" value="high" />
    <embed src="/flash/home-tv-reflection.swf" quality="high"
    pluginspage="
    http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"
    type="application/x-shockwave-flash" width="344"
    height="400"></embed>
    </object>
    </noscript>
    </p>
    <h3>Complete Digital Signage Solution</h3>
    <p align="left"><strong>Citecast is a turnkey,
    worry free digital signage solution</strong> that includes
    content, appropriate hardware, software, installation, training and
    support. </p>
    <p align="left">Need it quickly? Citecast can be
    deployed rapidly so that you are up and communicating fast.
    We make it easy to try Citecast with a low cost of entry and
    reasonable monthly usage fees. There is no need to purchase
    expensive equipment or grow and train your staff. </p>
    <p align="left">A Citecast Solution is high end
    digital signage without a huge capital investment.
    Citecast’s affordable options offer alternatives to
    costly capital expenditure by allowing you to use existing
    operating or marketing budgets. </p>
    <div class="spacershad"></div>
    <h3 align="center" class="twoColElsRtHdr">Compelling
    digital signage at the point of decision! </h3>
    <p class="text1">
    What is it worth to you and your organization to have a
    sales representative who is always in the right
    place to interact with the right people when they are at the
    point of decision? What is it worth
    to have representation that is informative, always accurate,
    and up-to-date delivering an efficient,
    positive, message to a captive market in at their point of
    decision. </p>
    <p class="text1"><a
    href="/Pages/Products_and_Services/Examples.shtml">View Citecast
    examples </a>
    <!-- end #mainContent --></div>
    <!-- This clearing element should immediately follow the
    #mainContent div in order to force the #container div to contain
    all child floats --><br class="clearfloat" />
    </div>
    <div class="clearfloat"></div>
    <div id="footer">
    <p></p>
    <!-- end #footer --></div>
    <!-- end #container -->
    </div>
    <script type="text/javascript">
    <!--
    var Accordion1 = new Spry.Widget.Accordion("Accordion1");
    //-->
    </script>
    </body>
    </html>

    Can't see your CSS code this way. Much better to publish to a
    testing
    folder on your remote server.
    But as a guess, I think this might work. Add this to your
    outer div's CSS.
    #mainContent {
    height: 1%; /** IE6 peekaboo fix **/
    overflow: auto; /** Mozilla clear floats **/
    --Nancy O.
    Alt-Web Design & Publishing
    www.alt-web.com
    "Dad Blame" <[email protected]> wrote in
    message
    news:[email protected]...
    > I have <div id="sidebar1"> that floats right,
    inside of <div
    id="mainContent">
    > which houses all the content. IE won't allow the text to
    extend (wrap) the
    > entire width of <div id="mainContent"> once it is
    past or below <div
    > id="sidebar1"> that floats right. Firefox allows it
    and displays
    correctly. I
    > am using SPRY widgets in <div id="sidebar1">
    > Below is the code...
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
    Transitional//EN"
    > "
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    > <html xmlns="
    http://www.w3.org/1999/xhtml">
    > <head>
    > <meta http-equiv="Content-Type" content="text/html;
    charset=utf-8" />
    > <title>Citecast Digital Signage</title>
    > <link href="/CSS/twoColElsRtHdr.css" rel="stylesheet"
    type="text/css" />
    > <!--[if IE]>
    > <style type="text/css">
    > /* place css fixes for all versions of IE in this
    conditional comment */
    > .twoColElsRtHdr #sidebar1 { padding-top: 30px; }
    > .twoColElsRtHdr #mainContent { zoom: 1; padding-top:
    15px; }
    > /* the above proprietary zoom property gives IE the
    hasLayout it needs to
    > avoid several bugs */
    > </style>
    > <![endif]-->
    > <script src="Scripts/AC_RunActiveContent.js"
    type="text/javascript"></script>
    > <script src="SpryAssets/SpryMenuBar.js"
    type="text/javascript"></script>
    > <script type="text/javascript"
    src="p7pm/p7popmenu.js"></script>
    > <script src="SpryAssets/SpryAccordion.js"
    type="text/javascript"></script>
    >
    > <style type="text/css" media="screen">
    > <!--
    > @import url("p7pm/p7pmh7new.css");
    > -->
    > </style>
    > <link href="SpryAssets/SpryAccordion.css"
    rel="stylesheet"
    type="text/css" />
    > </head>
    >
    > <body class="twoColElsRtHdr"
    onload="P7_initPM(1,7,1,-20,10)">
    >
    > <div class="twoColElsRtHdr" id="container">
    >
    >
    > <div id="header">
    >
    > </div>
    >
    > <!-- end #header -->
    >
    >
    >
    > <div id="container_margintop">
    >
    > <div id="menu">
    > <!--#include
    virtual="/includes/citecastmenu-NEW.html" -->
    > </div>
    >
    >
    >
    > <div id="sidebar1">
    > <div id="Accordion1" class="Accordion"
    tabindex="0">
    > <div class="AccordionPanel">
    > <div class="AccordionPanelTab">Research shows
    digital signage is more
    > memorable, less annoying than other media</div>
    > <div class="AccordionPanelContent">
    > <p>
    Caveats to keep in mind ...</p>
    > <p>Like any research sponsored by a party with a
    vested interest in
    the
    > outcome, these results need to be taken with a grain of
    salt. </p>
    > <p> <a
    href="/Pages/articles-columns-news/researchShows...caveats
    to
    > keep in mind.shtml">more ...</a> </p>
    > </div>
    > </div>
    > <div class="AccordionPanel">
    > <div class="AccordionPanelTab">Research shows
    digital signage is more
    > memorable ...
    What does it all mean?</div>
    > <div class="AccordionPanelContent">
    > <p>Some of the above results simply indicate how
    much time the
    > respondents spend interacting with each type of media.
    </p>
    > <p><a
    href="/Pages/articles-columns-news/researchShows...what does
    it
    > all mean.shtml">More ...</a> </p>
    > </div>
    > </div>
    > </div>
    > <br />
    > <br />
    >
    >
    > <div align="center"><img
    src="/Images/clarkpowell-integrator-logo.png"
    > alt="clark powell" width="214" height="69"
    /></div>
    >
    > <div align="center"><img src="/Images/cp 25yr
    seal.png" /></div>
    > <br />
    > <div align="center"><img
    src="/Images/princeton_logo_horiz.jpg"
    > alt="princeton" /></div><br />
    > <br />
    >
    >
    > <!-- end #sidebar1 --></div>
    >
    > <div id="mainContent">
    > <h1 align="center"> </h1>
    > <h2 align="center">Turn Key Digital
    Signage</h2>
    > <p align="center">
    > <script type="text/javascript">
    > AC_FL_RunContent(
    >
    'codebase','
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.
    cab#
    >
    version=9,0,28,0','width','344','height','400','title','Citecast
    digital
    > signage
    >
    example','src','/flash/home-tv-reflection','quality','high','pluginspage','h
    ttp:
    >
    //www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFla
    sh',
    > 'movie','/flash/home-tv-reflection' ); //end AC code
    > </script>
    > <noscript>
    > <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    >
    codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.ca
    b#ve
    > rsion=9,0,28,0" width="344" height="400" title="Citecast
    digital signage
    > example">
    > <param name="movie"
    value="/flash/home-tv-reflection.swf" />
    > <param name="quality" value="high" />
    > <embed src="/flash/home-tv-reflection.swf"
    quality="high"
    >
    pluginspage="
    http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Ve
    rsio
    > n=ShockwaveFlash" type="application/x-shockwave-flash"
    width="344"
    > height="400"></embed>
    > </object>
    > </noscript>
    > </p>
    >
    > <h3>Complete Digital Signage Solution</h3>
    > <p align="left">
    Citecast is a turnkey, worry free digital
    signage
    > solution that includes content, appropriate
    hardware, software,
    > installation, training and support. </p>
    > <p align="left">Need it quickly? Citecast can be
    deployed rapidly
    so
    > that you are up and communicating fast.
    > We make it easy to try Citecast with a low cost of entry
    and
    > reasonable monthly usage fees. There is no need to
    purchase expensive
    equipment
    > or grow and train your staff. </p>
    > <p align="left">A Citecast Solution is high end
    digital signage
    without
    > a huge capital investment.
    > Citecast?s affordable options offer alternatives to
    costly
    capital
    > expenditure by allowing you to use existing operating or
    marketing
    budgets. </p>
    > <div class="spacershad"></div>
    > <h3 align="center"
    class="twoColElsRtHdr">Compelling digital
    signage at
    > the point of decision! </h3>
    > <p class="text1">
    > What is it worth to you and your organization to have a
    sales
    > representative who is always in the right
    > place to interact with the right people when they are at
    the
    point of
    > decision? What is it worth
    > to have representation that is informative, always
    accurate, and
    > up-to-date delivering an efficient,
    > positive, message to a captive market in at their point
    of
    decision.
    > </p>
    > <p class="text1"><a
    >
    href="/Pages/Products_and_Services/Examples.shtml">View Citecast
    examples
    </a>
    >
    > <!-- end #mainContent --></div>
    > <!-- This clearing element should immediately follow
    the #mainContent
    div
    > in order to force the #container div to contain all
    child floats --><br
    > class="clearfloat" />
    > </div>
    >
    > <div class="clearfloat"></div>
    >
    > <div id="footer">
    > <p></p>
    > <!-- end #footer --></div>
    > <!-- end #container -->
    >
    > </div>
    >
    > <script type="text/javascript">
    > <!--
    > var Accordion1 = new
    Spry.Widget.Accordion("Accordion1");
    > //-->
    > </script>
    > </body>
    > </html>
    >
    >

  • MARM Conversion Result Drops Decimal?

    A new Material conversion was created in MM02 for a Karton....'KAR'. The conversion is KG to KAR.
    The original ABAP logic was zresult = 102 / 5. This should equal 20.4: 
    The code used
    marm-umrez = marm-umrez / marm-umren
    the result is 20, missing decimal value.
    I understand that umrez and umren are not decimals so a decimal cannot be assigned to the result so I tried this:
    DATA: znew_value(5) type p DECIMALS 3.
    DATA: umrez_new(5) type p DECIMALS 2.
    DATA: umren_new(5) type p DECIMALS 2.
    umrez_new = marm-umrez .
    umren_new = marm-umren.
    znew_value = umrez_new / umren_new.
    I still get 20 instead of 20.4?
    I have played with the syntax unpack, write to, assign to, and move to, but my syntax cold have been off.
    Can anyone suggest how I can use, or define a new field, or fields to pass them into so that I will get the decimal value after the calculation? Or, possible syntax for calculating the result using the original fields that will have the decimal value.
      Thank-You

    Hi,
    From ur code, I written the below code.
    DATA: znew_value(5) type p DECIMALS 3.
    DATA: umrez_new(5) type p DECIMALS 2.
    DATA: umren_new(5) type p DECIMALS 2.
    DATA: marm TYPE marm.
    marm-umrez = 102.
    marm-umren = 5.
    umrez_new = marm-umrez .
    umren_new = marm-umren.
    znew_value = umrez_new / umren_new.
    BREAK-POINT.
    Its giving the perfect result.
    Can you try this one in a test program. If this one is working in SE38 program then its a arithmetic problem of any routine. :P
    To overcome this one you have to write one small FM and build the logic there. Its a magic
    Regards
    Subhankar
    Edited by: Subhankar Garani on Oct 27, 2011 7:11 PM

  • Keyfigures :decimal vs floating

    Hello,
    Currently we are working with decimal key figures.But now onwards we are going to work with floating point key figures.
    I want to know will there be any repercussions of it from performance point of view...??

    Hi.
    There will be no impact on performance as it is just the format and calculations take same time as it happens in binary format in background.
    I hope it will help.
    Thanks,
    S

  • Different results for decimal values between SQL and B1 RecordSet

    Hi Experts,
    This is really a strange one. I have the query below:
    SELECT Amount, TaxPrcnt FROM [@Table] WHERE ORDER# = '20246' AND ItemCode = '112488'
    The same query gives me 0.085 for TaxPrcnt if I run it in SQL Management Studio, but gives me 8.5 if I run it in B1 Query Generator, and the same if I use RecordSet object in DI. The actual value in the table is 0.085. Anyone know why B1 is multiplying the value by 100?

    Hi Ronnie,
    sp_prepexec is a system stored procedure used to generate  to prepare and execute a parameterized SQL statement. Have a look at:
    http://jtds.sourceforge.net/apiCursors.html#_sp_prepexec
    Basically, it's another way of passing a query to SQL rather than using a stored procedure. This command shouldn't be converting the data in any way, unless there's a specific cast or calculation in the query itself.
    Can you give simple details of the SQL table you created and I'll see if I can replicate the issue.
    Kind Regards,
    Owen
    P.S. Sorry about the query, I wrote that down this morning before all my brain cells were awake Referencing a field by index only works when grouping and sorting.

  • How to divide result in 80/20

    Hi
    I have bit different requirement.
    I have table A which has 1000 records.
    Now I was insert 80% of record from table A into Table B80
    and remaining 20% in C20
    How can I do that.

    A more generic way using a single insert statement would be something like...
    insert all
      when grp = 0 then
        into b80 (... columns ...)
        values (... columns ...)
      when grp = 1 then
        into c20 (... columns ...)
        values (... columns ...)
    select ... columns ...
          ,case when row_number() over (order by 1) / count(*) over () <= 0.8 then 0 else 1 end as grp
    from ae.g.
    SQL> create table emp80 as select * from emp where 1=0;
    Table created.
    SQL> create table emp20 as select * from emp where 1=0;
    Table created.
    SQL> select * from emp80;
    no rows selected
    SQL> select * from emp20;
    no rows selected
    SQL> ed
    Wrote file afiedt.buf
      1  insert all
      2    when grp = 0 then
      3      into emp80 (empno, ename, job, mgr, hiredate, sal, comm, deptno)
      4      values (empno, ename, job, mgr, hiredate, sal, comm, deptno)
      5    when grp = 1 then
      6      into emp20 (empno, ename, job, mgr, hiredate, sal, comm, deptno)
      7      values (empno, ename, job, mgr, hiredate, sal, comm, deptno)
      8  select empno, ename, job, mgr, hiredate, sal, comm, deptno
      9        ,case when row_number() over (order by 1) / count(*) over () <= 0.8 then 0 else 1 end as grp
    10* from emp
    SQL> /
    14 rows created.
    SQL> select * from emp80;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7369 SMITH      CLERK           7902 17-DEC-80        800                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
    11 rows selected.
    SQL> select * from emp20;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
    SQL>

  • Wrong result for decimal in currency

    Hi All,
    I loaded the history data by pc_file to the bw systems and when ı check the data in the infocube and in the source file, they are same. But when ı executed the report, for example the value of the keyfigure in the cube and source file is 118,36 but in the report it seems 11836,00.   How can it happen??
    Please help me on this.
    Regards,
    Turan

    Hi,
    There could be scaling used in the reports.
    just go to the properties of the RKF and CKF and also key figures and see if some scaling ( *100)is used.
    Also try to see if u are making correct inetrpreatation of ,(comma) and .(dots)
    Thanks
    Ajeet

  • Convertion Hex String to 32bits Decimal floating point??

    Hi,
    I would like to know how to convert hexa like: 416b0ac3 in decimal 32bits floating-point. The result of this string is suppose to be 14.690127.
    So i must be able to do:
    From 32-bit Hexadecimal Representation To Decimal Floating-Point
    Thanks for your support
    RiderMerlin

    RiderMerlin
    You can use the typecast function to do this.
    David
    Message Edited by David Crawford on 09-06-2006 03:31 PM
    Attachments:
    Typecast to Single.jpg ‏6 KB

  • Is it possible to convert a float to two decimal places

    Can anyone help me to convert a float to two decimal places
    float f=16;
    System.out.println(f);
    It will print 16.0
    But I want to get printed as 16.00

    "convert" no, as no conversion is needed, obviously. Format the output, yes. Read the API for String and its printf method.

  • SQLT_NUM mapping to int, float, decimal

    Hi there,
    I use OCI calls to get the data type of my attributes. OCI treats integer, decimal and float as SQLT_NUM type internally. I use OCCIAttrGet() to get the scale and precision of these data types. How do I classify them as int, float and decimal based on scale and precision??
    Thanks,
    Sashi

    If scale = 0 then use int (watch out for ranges though - Oracle can hold integers far greater than the int datatype can hold).
    If scale > 0 then you use either float or decimal (I assume you mean double). I suppose which one you use depends on the range of values / precision required.
    Adrian

  • Int or float

    Hello,
    In my J2ee server, I have a lots of computation of money. Usually, the primitive type float is satisfied for presenting money. But I have a question, is it better to use int to store it. Even in database, I can save more space by using INT than using DECIMAL(10,2). My MySql, INT requires 4 bytes, DECIMAL(10,2) requires 12 bytes. At I/O moudle, I just simply multiply 100 for input and divid 100 for output. Because I suspect that using float may change a tiny bit at the end of the value. Any suggestions to me?
    Thanks!

    How are we saying opposite things? I said that he should use an int unless it doesn't matter if the results of a calculation are actually correct. Floats/doubles are generally a bad idea to use unless you know what you are doing, since the approximating effect they have on calculations can be strange to a newcomer. For printing the results of money calculations, floats might work fine. However, you will get a certain amount of error, so you just have to watch out. If you are not storing the results of calculations where the operands are floats, then the error might be ok.
    Rounding in accounting programs, like interest programs always have very specific business rules that specify to what degree of precision the calculation is to be performed and which style of rounding should be used. I most programs that need to deal with money, the smallest increment will usually be a cent (for US money anyway). And if they don't have specific rules, then maybe you should get some (or stash the error into an account in your name, Superman 2 thank you very much).
    BigDecimal is fine to use if you don't need to worry about speed, and if you have the possibility of overflow with longs, BigDecimal is probably a good idea since it can represent huge numbers that long cannot. I would imagine that most programs don't need more precision then a long can provide.

  • How to divide two int numbers and get a fraction ?

    I am dividing two int numbers and the result should be a fraction but I am always getting a zero
    set @result= @num1/@num2  
    when num1=50 and num2=100

    I am dividing two int numbers and the result should be a fraction but I am always getting a zero
    set @result= @num1/@num2  
    You can either one of the values as a decimal or float type, or just multiply one of the values by 1.0.
    set @result= @num1/@num2*1.0
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Floats sinking

    I'm trying (for the first time) to do some floating point arithmetic. However, the following code ends
    double swing;
    swing = 1.25;
    swing = 30.2 / 28.1;I was rather expecting a value like 1.0747 in the final 'swing' but it is 1.0?!??
    What did I miss?

    I've found the problem. I was dividing two integers, which even though the result was (logically) a float, gave an integer.
    BEFORE:
    int x = 30;
    int y = 28;
    double swing;
    swing = x / y;
    // swing is now 1.0AFTER:
    double x = 30;
    double y = 28;
    double swing;
    swing = x / y;Don't really understand why this is the case though.

  • Wrong result in multiplication

    Hi, everybody!
    I have a problem with a simple multiplication for which I have not found a solution yet. And I do just hope, that anyone here has encountered and solved it already.
    The problem is as follows:
    JW = (long)(Math.floor(SOLZJ*100));
    JW is a long, SOLZJ is a float. At the crucial moment, SOLZJ contains the value of 582.72. The result, which JW contains, after computing the expression is 58271. So, you see, something went terribly wrong. As it is a variable, which is used in some further calculations, the error exponentiates.
    Sure hope, anyone can help me with that.
    By the way... I tried to use this expression outside of my method (to eliminate possible inherited errors). The following piece of code gets the same result as mentioned above:
    float SOLZJ = 582.72F;
    long JW;
    JW = (long)(Math.floor(SOLZJ*100));
    System.out.println(""+JW);
    Result is 58271 instead of 58272...
    Thanks for helping me out,
    Matthias

    what im saying is that a programming language is a box of tools, you use these to build applications (bigger, better tools)
    there are a few distinct phases a program has
    data aquisition
    data formatting
    data maipulation and calculation
    if you find that the tool you are using does not perform the task, use another one, if it does not exist, build it
    it is in the nature of floating point numbers/calcualations on comoputers that errors are normal, small compared to the numbers involved (hopefully)
    one such 'problem' was that a financial caluclation came out 'wrong' by a billionth of a penny, wrong, but hey, who cares..
    BigDecimal will solve this problem, but maybe overkill
    if you require say 2 demimal point accuracy, then you could easily write your own class that holds the data as an int (value *100)

Maybe you are looking for