Displaying results with a decimal place of two. Forcing decimal place.

Hi there,
Im writing a simple calculation device.
You input one digit and press one of two buttons to multiply it by a certain number and then the result is displayed. The result is displyed hiding the result of the button you didn't press and visa versa.
I am having a problem displaying the result with a constant two decimal place.
I am using strings and thus don't know how to do this.
Here is my code:
import flash.events.MouseEvent;
//restrict the input textfield to only numbers
txtinput.restrict = "0-9";
//restrict the input textfield to only two characters
txtinput.maxChars = 6;
// event listeners
btnW.addEventListener(MouseEvent.CLICK, WHandler);
btnC.addEventListener(MouseEvent.CLICK, CHandler);
btnW.addEventListener(MouseEvent.CLICK, hideC);
btnC.addEventListener(MouseEvent.CLICK, hideW);
//functions
function WHandler (e:MouseEvent):void
          //white calculation
          var answerW:Number = Number(txtinput.text) * Number(0.90);
          txtWResult.text = answerW.toString();
function CHandler (e:MouseEvent):void
          //colour calculation
          var answerC:Number = Number(txtinput.text) * Number(0.99);
          txtCResult.text = answerC.toString();
function hideC (e:MouseEvent):void
          //Hide colour result
          txtCResult.visible = false;
          txtWResult.visible = true;
function hideW (e:MouseEvent):void
          //Hide white result
          txtWResult.visible = false;
          txtCResult.visible = true;
After having a look online I have found these two resources:
http://helpx.adobe.com/flash/kb/rounding-specific-decimal-places-flash.html
and
http://stackoverflow.com/questions/11469321/decimals-to-one-decimal-place-in-as3
But I am confused when combining these techniques with strings.
Any help would be greatly appreciated,
Thanks in advance
Mr B

Use the toFixed() method of the Number class instead of the toString() method.  The result of it is a String with the number of decimal places you specify.
          var answerW:Number = Number(txtinput.text) * Number(0.90);
          txtWResult.text = answerW.toFixed(2);
          var answerC:Number = Number(txtinput.text) * Number(0.99);
          txtCResult.text = answerC.toFixed(2);

Similar Messages

  • Displaying Currency with three decimal places in smartform

    hi abap experts~~
    I'm wondering that how to convert numeric type to currency type.
    for example below.
    ex) 2346.856 --> 2.346,856
    please help me to solve the problem..
    Regards,
    Himanshu

    Hi Himanshu,
    This depends on the SU3 settings of ur system. GO to
    tcode SU3>Defaults->decimal notation..
    There change to ur desired type and relogin.
    The format will change...

  • Incorrect query result with Top N condition and two structures

    Hi,
    I have created a query on a FI-GL infocube with the characteristic 0BUS_AREA in rows and two structures in columns. The first structure has two items / selections (each item is a selection of several GL accounts). The second structure has two items (the first one contains the key figure 0BALANCE for the current period and the second item is a formula that calculates the absolute value of the first item. The first item is hidden). The (simplified) result looks like this (sorry, not very pretty!):
    Business Area Clients Clients fae
    Business Area1 10 15
    Business Area2 20 7
    Business Area 3 15 8
    Overall result 45 30
    I then added one condition using the Top N operator. The condition is defined for all the elements of the structures. When I execute the query, I sometimes obtained an incorrect number of Top N records selected. The problem seems to occur when N is greater than the number of available Business Areas for an element of the structure.
    For example, if N = 8 and data only exists for 5 Business Areas for the structure element Clients, I may end up with 10 Business Areas for the second structure element Clients fae when I only expect 9 (i.e. the top 8 Clients fae + 1 of the Top 8 Clients for which there is no data under Clients fae).
    Has anybody encoutered that kind of problem ?
    Many thanks.
    François.

    Pascal,this is a known behavior with conditions.When you apply condition it just hide the extra rows and it does not impact the result row.So your result row actually shows the value irrespective of the condition you apply.
    Now with the help of local functions like calculate result as summation you can show the correct sum after applying the condition but when you try to use that result in some calculation then it takes the original value thereby discarding the calculated value.
    Same is happening in your case as well.Its taking the original value i.e 350 and not the calculated sum after condition i.e 270.
    Hope this helps.
    Regards,
    AL

  • Slow display results with Fill() metod

    When I access database with 100 000 and more records
    and try to display page from end of database, fill method from DataAdapter is very slow. Maybe someone know solution for this problem ?
    sample code:
    start = 100000
    paczka = 500
    cn_all_catalog.ConnectionString = strconnection
    cn_all_catalog.Open()
    da = New od.Client.OracleDataAdapter(query_string, cn_all_catalog)
    da.Fill(DataSet1, start, paczka, "MyTable")

    You can play around with the FetchSize property of OracleCommand class to tune your application. You can set FetchSize to a large value to make less number of round trips to the database to fetch 100,000 rows but that would result in higher memory requirement on the client side.

  • Displaying results with comma

    Hi i have two tables that have a one-to-many relationship and i want to display the output as comma delimitters. The two tables are
    TABLE TABLE1
    OVERSION_ID NUMBER NOT NULL,
    PREVIOUS_V_ID NUMBER NOT NULL
    TABLE TABLE2
    OVERSION_ID NUMBER NOT NULL,
    so for example if i run the query
    select * from table1
    the result is
    OVERSION_ID PREVIOUS_V_ID
    12456 25677
    12456 25702
    12456 27897
    how can i write an sql query that will display all previous_v_id seperated by a comma like below
    25677, 25702, 27897
    Thank you very much.

    i have used the wm_concat function and it worked
    select oversion_id, wm_concat(previous_v_id) from table1 group by oaversion_id;
    however i have 2 other tables
    TABLE TABLE3
    OVERSION_ID NUMBER NOT NULL,
    OID NUMBER NOT NULL
    TABLE TABLE4
    OID NUMBER NOT NULL
    ONUMBER VARCHAR2 NOT NULL,
    You can see the relation between table 3 and table 4
    how can I change the query
    "select oversion_id, wm_concat(previous_v_id) from table1 group by oaversion_id;"
    so that i get the output as onumber and not the previous_v_id
    in other words how can I join these tables so the output is not the numbers (previous_v-id) , but the varchar2 (onumber) from table4

  • Display amount in ALV Grid with different Decimal Places based on Currency

    HI Experts,
    Working with ALV Report i have one Amount field NETWR which is having Length 15 and Decimal Places 2.
    we have two different types of currency's AED and KWD and AED having 2 decimal Places and KWD having 3 decimal places.
    im using FM: REUSE_ALV_GRID_DISPLAY for Display. value storing in Table was like this
    AED---22.56
    KWD---225.65
    i need to display values like AED : 22.56

    HI Experts,
    Working with ALV Report i have one Amount field NETWR which is having Length 15 and Decimal Places 2. we have two different types of currency's AED and KWD and AED having 2 decimal Places and KWD having 3 decimal places.
    im using FM: REUSE_ALV_GRID_DISPLAY for Display. value storing in Table was like this
    AED---22.56
    KWD---225.65 (converting this value to 22.565 using BAPI_CURRENCY_GETDECIMALS according to currency in my Report)
    i need to display values like AED : 22.56
                                             KWD---22.565 but here field is NETWR with 2 decimal.
    Need to Display amount in ALV Grid with different Decimal Places based on Currency
    Regards,
    Dileep Kumar Reddy

  • Displaying all numbers with 2 decimal places

    Hi All,
    We have a requirement in our code where we want that all numbers must be diplayed with 2 decimal places.
    Eg: If a number is 21.234 then it should be displayed as 21.23
    If a number is 21.289 then it should be displayed as 21.28
    If a number is 21 then it should be displayed as 21.00
    Can anyone please help me how to do it in a SQL query.
    Regards,
    Shruti

    Hi, Shruti,
    This shows a couple of things you can do:
    COLUMN     trnc     FORMAT     999999.99
    WITH     got_x     AS
         SELECT     empno / 1000     AS x
         FROM     scott.emp
    SELECT     x
    ,     TO_CHAR (x,            '999999.99')     AS tc
    ,     TO_CHAR (TRUNC (x, 2), '999999.99')     AS trnc_tc
    ,     TRUNC (x, 2)                              AS trnc
    FROM     got_x
    ;Output:
    `        X TC         TRNC_TC          TRNC
         7.369       7.37       7.36       7.36
         7.499       7.50       7.49       7.49
         7.521       7.52       7.52       7.52
         7.566       7.57       7.56       7.56
         7.654       7.65       7.65       7.65
         7.698       7.70       7.69       7.69
         7.782       7.78       7.78       7.78
         7.788       7.79       7.78       7.78
         7.839       7.84       7.83       7.83
         7.844       7.84       7.84       7.84
         7.876       7.88       7.87       7.87
           7.9       7.90       7.90       7.90
         7.902       7.90       7.90       7.90
         7.934       7.93       7.93       7.93Column x is the number, as SQL*Plus displays it by default. Note there are as many digits after the decimal point as are needed.
    Column tc shows how TO_CHAR can format the number, with exactly 2 digits after the decimal point. This automatically rounds the number to the nearest multiple of .01, so on the first row (for example) 7.369 gets displayed as 7.37.
    user11272043 wrote:
    ... If a number is 21.289 then it should be displayed as 21.28You (apparantly) always want the number rounded toward 0, so column tc isn't quite what you want.
    Column trnc_tc is exacly what you requested, with the numbr rounded toward 0 (when any rouning is necessry) and 2 digits after the decimal point.
    Column tc is also exactly what you requested, but it uses SQL*Plus formatting rather than SQL. Also, column trnc is a NUMBER, while column trnc_tc is a VARCHAR2, because TO_CHAR, as its name hints, returns a VARCHAR2.
    The SQL*Plus command
    SET   NUMFORMAT  999999.99changes the default format for all number columns. If you use this, you can override it for individual columns by using TO_CHAR (since it returns a VARCHAR2, the NUMFORMAT doesn't apply),or a COLUMN command. Also, if you use SET NUMFORMAT 999999.99, you'll still have to explicitly TRUNC every number, or else 21.289 will come out as 21.29, not 21.28.

  • BEx Analyzer displays wrong number of decimal places after implementing BW patch

    Hey folks,
    we patched our BW 7.31 from PL10 to PL15 last weekend and now we got some issue with the number of decimal places shown in BEx Analyzer 7.x.
    One example for KF X
    Settings Info Object X
    Decimal Places:                         Not defined
    RSRT - Display X
    Shows 3 decimal places
    Query Designer Settings using KF X
    Number of Descimal Places:     0  [Use Default Settings: NO]
    BEx Analyzer Properties for KF X
    Decimal Places:                         0
    Resulting in BEx Analyzer workbook shows 3 decimal places instead of 0!
    Anyone with an good idea about that?
    Thanks,
    Andreas

    Hi Andreas,
    Have you used the list calulation like "Calculate Result As Average" or "Calculate Single Values as normalization of result" in the relevant key figures?
    For "Calculate Single Values as normalization of result",iIt is the known design that it is always displayed with three decimal places for normalized values, and the setting in Query Designer for
    decimal place doesn't take effect.
    For "Calculate Result As Average", the following note maybe relevant.
    2096911 - Decimal places in query result is wrong, if average is used and display precision is set to less than 3, it will always show 3 decimal places.
    Another clue is to check if the key figure is a Quantity type with unit, and what's defined in table
    T006 field ANDEC for this unit.
    Hope this helpful.
    Regards,
    Ceciclia

  • Mail will not display images with .jpeg extension. .jpg works fine. (displays in place when opening the email. What plug-in would correct this?

    Mail will not display images with .jpeg extension. .jpg works fine. (displays in place when opening the email. What plug-in would correct this?

    If you think you're insane now, try maintaining those pop up menus.
    As far as I know, these menus have not been updated since FW 8, so 
    they are at least two versions old.
    Save yourself a lot of grief by avoiding those menus. There are many 
    other products on the market which do a much better job of creating 
    and maintaining this type of navigation structure.
    Read this link before you climb any higher on this slippery slope:
    http://apptools.com/rants/jsmenu.php
    There was another blog post by the fellow who originally wrote the pop 
    up menu feature, but I can't seem to locate it. Even he says stay away 
    from them.
    Not the answer you probably want, but I hope it helps, nonetheless.
    Jim Babbage

  • !!!! How to maintain the value with 2 decimal places !!!

    hi
    i have a double var and i need to maintain it with 2 decimal places only..
    thanks..

    What do you mean with you need to "maintain it" with 2 decimal places?
    Do you want to display the number with 2 decimal places? If so, have a look at the API documentation of java.text.DecimalFormat.
    double d = 3.14159265358979;
    NumberFormat f = new DecimalFormat("0.00");
    System.out.println(f.format(d));

  • Currency conversion issue in SPM. We are getting incorrect results with SPM conversion function from one of the document currency to USD.

    Currently we are using SPM 2.0 version and we have been facing currency conversion issues.
    Please help me in following aspects.
    1) Where actually currency conversion happens in SPM. Is it the global program which does the conversion or other way.
    2) We have conversion issue for one of the currency where conversion function is giving incorrect results when converting from one of the document currency to USD. here The respective document currency is considering the 1:1 ratio with Dollar which is actually incorrect.
    3) We have verified in both BI side(currency tables) and even ECC side.
    Please help me in understanding this issue and let me know if you need more information on this.
    Its an production issue and appreciated your immediate inputs.
    Thanks
    Kiran

    Hi Arun,
    The following information may be helpful to you.The SSA_HELPER_PROGRAM has options regarding currency settings.
    EXCH_RATE_TYPE: This flag governs the exchange rate type which will be used for currency conversion in data management. For example if RSXAADMIN contains an entry EXCH_RATE_TYPE = „ZSPM‟ then the conversion type used for currency conversion is ZSPM. The default value for the exchange rate type is „M‟. More details can be found in the note 1278988.
    CURRENCYCONVERSION: By default data management converts all the measures in transaction currency to reporting currency and copies over to the corresponding measure in reporting currency. If the measure in reporting currency is already available in source it might be desirable to disable the currency conversion. To disable the conversion you can make an entry CURRENCYCONVERSION = „ „ in the table RSXAADMIN. This can also be achieved by running the program SSA_HELPER_PROGRAM with the option DEACTIVATE_CURRENCYCONVERSION. The conversion can be reactivated by running the same program with option ACTIVATE_CURRENCYCONVERSION.
    UNITCONVERSION: Similar to above. To deactivate unit conversion you can use the program with option and DEACTIVATE_UNITCONVERSION and to reactivate ACTIVATE_UNITCONVERSION. By default both the conversions are switched on
    EXTERNAL_CURRENCIES: Normally most of the international currencies are stored with two decimal places however certain currencies do have 0 and 1 decimal place too. For example JPY has 0 decimal places. SAP internal format stores even these currencies with 2 decimal places and at the time of display it changes the value to right decimal places. In case a file from external source is loaded to SPM it might have the format with 0 decimal places in the file. To convert it to SAP standard format post processing needs to be done on this value. If that is the case you can set the flat EXTERNAL_CURRENCIES = „X‟ in the table which will enable the post processing for these values. This flag can also be set and reset using the helper program using the option TURNON_EXT_CURRENCY_FORMAT and TURNOFF_EXT_CURRENCY_FORMAT.
    Kind Regards,
    John Harris
    Senior Support Engineer, SAP Active Global Support

  • How do I display results (anywhere) from the SequenceFileLoad Step?

    I want to be able to display the results from the SequenceFileLoad Sequence after the Sequence has been loaded to a window in a customized version of the CVI Test Executive User Interface. I can't seem to find where this Sequence gets called from in the Process Model (breakpoints are ignored), assuming that is where I want to make my changes.

    There are 3 types of callbacks: Model, Engine and FrontEnd callbacks (see table 1-1 and table 6-4 of the TS 2.0 User Manual).
    What differentiates these types are
    1) Where the callback sequences are located.
    2) What calls the callback.
    The SequenceFileLoad callback is an engine callback. This means that it is called by the TS engine and not your model. You place the callback in the sequence file, for which upon opening, you want the callback to run.
    Since the engine is executing this callback you have no control over parameters that are passed into or out of the sequence. In addition, the file global and local variables of the executed SequenceFileLoad callback are lost when the execution completes.
    You could have the callback write the values of
    Locals.Result to a file or station globals so that the information is available after the execution completes. There are even temporary station globals (see Engine.TemporaryGlobals) that allow you to keep hidden station globals variables that does not get written to the StationGlobals.ini upon shutdown of your station. These hidden variables do not appear in the station global window.
    Attached is a starting point for you. When you open this sequence file the Load callback puts its results into a temporary (hidden) station global. When you run the MainSequence, a subsequence is called that replaces its results with those contained in the temporary station global. This only occurs if the global exists. The subsequence also deletes the temporary global. The results appear as the results of the sequence call step in the MainSequence.
    By the way, you enable tracing into the engine callbacks by checking the station option, "Trace Into Separate Execution Callbacks".
    Attachments:
    SeqFileLoadResults.seq ‏30 KB

  • Does anyone else have display issues with Intel X3100 graphics and OS X Lion?

    I took the screenshot below to demonstrate one issue I have had with graphics since upgrading to OS X Lion. I use a Late 2007 MacBook with 2.0GHz Core 2 Duo and the Intel X3100 graphics chipset. I have 4GB RAM. Had to reboot to get this to correct itself. The problem is the menubar (obvious) and the desktop image is missing, replaced by the grey.
    I have an external monitor connected (second image) and everything displays properly there.
    Some other issues I've noticed are using Mission Control sometimes yields unpredictable results, graphically speaking, and the fullscreen apps don't always allow me to see the menubar. These all seem graphically related. Is this a hardware or software problem? Any solutions?

    Here is another display issue with my machine...perhaps software rather than hardware? The icon for the rtf file "Matt Passages" is missing entirely. There is a faint rectangle present instead. The same file has an icon in the first image posted above. No change to the file since then. And two other RTFs have the icon! Odd things with Lion.

  • Display Issues with mini (Mid 2010) and LG L246WP

    I recently purchased a new mini (Mid 2010 base model) and planned to use it with my 24" LG L246WP monitor, which is about 3 years old. The monitor has VGA, component, and HDMI inputs.
    I used an HDMI-to-HDMI cable to connect the mini directly to the monitor, and the output is completely messed up. The mini recognized the monitor (titling the System Preferences > Display dialog with 'L246WP') and set it to the monitor's native resolution of 1920x1200, but on the monitor the image is cropped to what looks like a 4:3 aspect ratio and with part of the image shifted up and left so I cannot view the top menu bar or the left hand side of the desktop. The monitor's on-screen display shows 1080p in this mode.
    The Display dialog also gives me an option for 1080p. I can select this and use the Underscan slider to resize the desktop output to fit on the screen, but it is still shifted left and must be resized smaller than the available display space (plus the total image is only 1080 pixels, not using the monitor's full native screen). In this mode, 1080p also shows on the monitor's on-screen display.
    I tried 1024x768 to see if I could get a properly-positioned image, but the desktop was shifted just like in the 1920x1200 case and the monitor's on-screen display status still reported 1080p.
    The monitor has a menu setting under an HDMI heading with "Video" and "PC" options, but changing this selection does not make a difference.
    Since the monitor came out before HDMI was as widespread as it is today, it came with a DVI-to-HDMI cable, so I also tried using that cable with the HDMI-to-DVI adapter that came with the mini, but this did not make a difference either.
    To prove it wasn't the HDMI cable, I connected the mini to my Samsung 6300 series 40" LED HDTV and with some tweaking of the Underscan slider the displayed image filled the screen perfectly.
    I've searched the Internet and various forum threads (i.e. http://hardforum.com/showthread.php?t=1167222&page=63) seem to indicate this monitor can send a corrupted EDID that causes issues, especially with nVidia graphics drivers. On Windows you can use registry or driver hacks to override the EDID with the correct values, but on OS X this doesn't seem possible (I was hoping for a Terminal one-liner but it seems this doesn't exist). I have seen some mentions of the shareware SwitchResX (http://www.madrau.com), which looks like it gives you the option to override resolution settings, but I haven't tried this yet.
    It also appears to me that the monitor is always interpreting the signal (or the mini is always sending the signal) as 1080p, even if I've set 1920x1200 in the Display dialog. I don't know if this is a defect in the monitor where it always assumes the HDMI input is a 1080p source (previous I used it with an Xbox 360 with no issues but that was 1080p HDMI), or if is a bug in the graphics drivers (or at least a lack of flexibility / miscommunication to the user trying to handle a corrupt EDID).
    I asked my local Genius Bar for advice today (without bringing any hardware in) but was not told anything I didn't already know.
    I'm trying to determine the best way to work through this issue. *My questions are:*
    Would it make any difference if I used a Mini DisplayPort-to-DVI adapter (and then my DVI-to-HDMI cable to the monitor's HDMI input)?
    What about a Mini DisplayPort-to-VGA adapter? In the past I used a 12" Powerbook (via a mini-DVI-to-VGA adapter) with this monitor and had no display issues like this, but I'd prefer to stick with a digital connection on my brand new mini.
    Is SwitchResX the only practical way in OS X to override a corrupt EDID and force the mini to output a certain resolution?
    Besides the various adapters and SwitchResX, is there anything else I should try before buying a new monitor?

    Hello EPWilson4984.
    I have been experiencing the same issues you described. Connecting my brand new Mac Mini to my Westinghouse 24”monitor (L2410NM,  1920x1200 pixel resolution) produces a very fuzzy and washed out image quality. The Mac recognizes the monitor and applies the right resolution (1920x1200), but it looks just awful. The EDID info is definitely not right.
    Now, I tried your suggestion (DVI-to-HDMI), and similar suggestions from other threads, but nothing works. Nothing seems to work at all.
    The main input for the monitor is HDMI, so whatever cable I use, in the end always has to connect to the monitor via HDMI. I tried all these combinations with zero success:
    Mac mini -> HDMI cable -> monitor (result: fuzzy and blurry image)
    Mac mini -> displayport –HDMI adapter-> HDMI cable -> monitor (result: fuzzy and blurry image)
    Mac mini  -> displayport –DVI adapter-> DVI-to-HDMI cable -> monitor (result: it gives me a blank screen, no image at all)
    I’m running out of options. Don’t know what to do. The 24” monitor produces beautiful, crisp images when hooked to my Windows 7 PC. It looks horrible when connected to my brand new Mac Mini.
    Any alternatives you may have come across? Please let me know, thank you.

  • How to convert a number to FLOAT with 9 decimal values.

    Hi all,
    I need to convert a number like '10.02' to a floating point number with 9 decimal values like '10.022111221'. I think that the right function is TO_BINARY_FLOAT, but how can I obtain 9 decimal values? If I use the following syntax:
    select TO_BINARY_FLOAT(num) from table
    I obtain a floating point values with a variable number of decimal numbers after the ".", instead I need 9 number after ".".
    Regards,
    Maurizio.

    Hi,
    the number I need to select is the result of a product, for example:
    select (Num_A * Num_B) from Table;
    Num_A has 2 decimal numbers, like 12.01 and Num_B could be: 12.111111111.
    Now, Num_A * Num_B = 653.999999994
    but I issue:
    select TO_BINARY_FLOAT(54.00 * 12.111111111) from Table
    I obtain:
    654, a rounded value, but I need 653.999999994.

Maybe you are looking for

  • Version 9.4.3 not compatible with 9.5.1

    I have a MBP running Maveriks (OSX 10.9.5) and iPhoto 9.5.1 and an old iMac still running Lion (10.7.5) and iPhoto 9.4.3. When I copied an iPhoto library from my MBP to iMac iPhoto will not open it because it says it need a newer version of iPhoto -

  • How do I schedule a task at a specific time of day, every day?

    I am trying to use Timer and TimerTask to schedule an event at specific time of the day. It will basically stop all the logging archive the log file and start a new logfile. I am just having trouble with scheduling it for every day at specific time (

  • Silly Podcast approval question

    Ok this might be a silly question but when I submit a Podcast to my Podcast Producer server and choose to submit for approval it does the work and an email is sent to me telling me that it has been submitted for approval and the path to the files. Th

  • Save as PDF from Word 2007 missing graphics

    A similar question has been asked before, but it's still marked "unanswered" and I still don't know what's going on. All I really wanted to do today was update my resume... Sometime during the last two months of 2014, I lost the ability to see graphi

  • Recent install -- trouble with KDE -- tmp directory solution?

    I recently installed Arch and got KDE installed, but could only logon to KDE as root. I found that the /tmp directory appeared to not give regular users any rights and did a chmod on the directory. Now I am curious if I needed to do that or if there