Can't figure out how to solve the decimal point bug in this calculator code

Hi guys, I'm new in flash and is currently learning how to build a simple calculator with multipliers (plus,minus,multiple,divide,decimal point and change sign) but I'm stuck on the decimal point and change sign.
var multiplier_old:Number = 10;
var multiplier_new:Number = 1;
// .: Sets the multipliers so that new input numbers become decimals of a lower unit column
action_point.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
          multiplier_old = 1;
          multiplier_new = 0.1;
          point = true;
// Takes intput from the input_ buttons and adds it to the input after applying the multipliers.
// If `point` is true then the multiplier_new is divided by 10, also as described.
function inputNumber(n:Number):void {
          input = input * multiplier_old + n * multiplier_new;
                    if (point) {
                                    multiplier_new *= 0.1;
                   trace(multiplier_new);
          output_txt.text = input.toString();
Decimal point
The problem is that when I input 2.7 in the calculator, it will display the values in output_txt correctly. But then when I input 2.78, it will display 2.780000000000000000000000002. This will also happen to other numbers if the input is too big.
What I want is just 2.78. How do I change the codings to make 2.780000000000000000000000002 become 2.78?
Change sign
Any tips on how to start on this one?
Thanks for your time,
Zainu

I think you misunderstand what I mean. The weird decimal doesnt comes out after I press the 'equals' sign. It comes out when im just pressing on the caculator number buttons
First I click the no.2 button and then the decimal point button.
So the caculation output display will show
2.
after that I press the no.7 button
2.7
and then no.8 button. It appears like
2.7800000000000000002
This is the code I use when the user press the decimal point button.
// .: Sets the multipliers so that new input numbers become decimals of a lower unit column
action_point.addEventListener(MouseEvent.MOUSE_DOWN, function():void {
          multiplier_old = 1;
          multiplier_new = 0.1;
          point = true;
// Takes intput from the input_ buttons and adds it to the input after applying the multipliers in the method described above.
// If `point` is true then the multiplier_new is divided by 10, also as described.
function inputNumber(n:Number):void {
          input = input * multiplier_old + n * multiplier_new;
                    if (point) {
                             trace(multiplier_new.toFixed(3));
                              multiplier_new *= 0.1;
                              //trace(multiplier_new);
          output_txt.text = input.toString();
I think there is some code wrong in this function that makes this weird problem. I tried putting toFixed method but it's still not working.
Sorry for this long reply but I have to try my bestto explain with my bad english.

Similar Messages

  • Anyone figure out how to solve the 1015 error

    anyone figure out how to solve the 1015 error

    Each version of Photoshop has its own installation path therefore a different application as fars as Wacom Configuration.  You would need to set preferences for each Photoshop installed on your system.  However if you know XML.  Wacom Tablet Preference File Utility can save your Wacom preferences into an XML file.  That you may be able to duplicate a Photoshop install and the change the Photoshop Path. Or just change the prion version pathe the the new Photoshop path then restore your Wacom Preferences using the modified XML preference file.
    Here you see part of my wacom preferences I have set preferences for all Photoshop installed on my workstation.

  • Can't figure out how to change the bottom margins

    This is my 3rd day with a mac and I can't figure out how to change the margins in Pages '09 so that it doesn't include a .5 margin on the bottom.
    I'm using a HP OfficeJet J6450. In the page setup, I changed the "untitled" user defined margins to .1 for top and sides and 0 for the bottom and it still includes a .5 margin on the bottom. Changing the untitled seems to help side margins.
    I've used the inspector to see if there is a setting there that defines the bottom margin as .5 and that doesn't seem to do it.
    If I print borderless, the text boxes that I have a .3 border around don't print on the edges even though they show up on my workspace. It also throws off the top and bottom.
    This is a big assumption, but I assumed that if the workspace and rules show white space and now grayed out, it would print that way. It's not.
    Any ideas? Thanks! Ana
    P.S. I've downloaded & installed updates for everything - OS, iWorks, Printer

    Peggy,
    Maybe this is true of Macs? On my windows systems - I can specify more options on both my printers and can print beyond .5 inches at the bottom. One specific option on my J6450 that I can select is "minimize borders" and it will print about .1 or .2 from the edge. On my mac, I do not have that feature to select. If I print borderless, even though my layout shows it should not go off the paper, once printed it does.
    Thanks.

  • Can't figure out how to maximize the space on the page by increasing the column width

    Trouble with pages app:
    can't figure out how to maximize the space on the page by increasing the column width
    I have 3 columns and they have spaces btw them that I cannot close the gap on.

    Whatever the version, you can click on the gutter figure and edit it.
    Click once on the column and a second time on the Gutter measurement.
    Peter

  • Please help, I can't figure out how to use the cable modem...

    I'm visiting my sister in Baltimore, Maryland for about 3 weeks, and I want to set up the internet on my macbook so i don't have to keep using her powerbook g4. She has a Motorola Comcast Cable Modem set up for her powerbook, but I can't figure out how to find the info about her connection so I can copy it down into my computer. I keep going to her system preferences section and clicking the network button, but none of the various internet connections shown are actually the one she uses to connect. Please tell me where I can find her cable provider's info in her powerbook and where, in my macbook, i can enter this information and get on the internet.
    p.s. i don't know if this is necessary info, but with the motorola cable modem came an installation disk for if you wanted to use the usb drive cord instead, but that disk isn't even read properly in my macbook. like, it lets me open up the disk and see all the files on it but it doesn't automatically start up an installation wizard so i really have no way of installing the items on the disk.

    well, i can't really tell if i am only allowed one connection with this isp. basically, whenever i plug in the ethernet cord, all of the information gets filled in in the ethernet section of the network, except for the router info. there is router info filled in on my sister's computer whenever i plug the cord into her computer, though. does that mean i can't also use the modem for my computer? sorry, this is both my first time using a mac and my first time using anything other than dial-up, so i'm pretty lost. thanks for the info you've given me thus far.

  • I have an iPOD mini library and now have a IPhone 4S.  I updated my library and synced my phone to the library but can not figure out how to get the music library to download to my  iphone

    I have an iPod mini library which I have update. I now have an iPhone 4S which I have synced to the library using a MS XP computer. I can not figure out how to get the library to download to my iPhone?

    Thanks,  This caused me to go back and try again since the solution seemed so simple.  What I did was when it started downloading, it started with the iphones apps to my computer.  I did not want the apps downloaded on my computer so I stopped it.  If I would have waited, the music was uploaded right after the apps were downloaded.

  • I got an ipod touch from my friend, but can't figure out how to change the apple id to get games. Help?

    I got an ipod touch from my friend, but can't figure out how to change the apple id to get games. Help?

    Never mind, I got this.

  • The updated iPhoto program is cumbersome.  I am trying to create a Christmas card and can't figure out how to get the fold of the card on the left and not on the top of the card.  I had no trouble with this for the past two years.  Can someone help?

    The updated iPhoto program is cumbersome.  I am trying to create a Christmas card and can't figure out how to get the fold of the card on the left and not on the top of the card.  I had no trouble with this for the past two years.  Can someone help?

    Click on the Layout button lower right and choose a Vertical lyout from the dropdown

  • HT2602 I am stuck. I can not figure out how to get the microsoft office that is on my (admin) profile dock onto the dock for the other users on my mac. Can anyone help me out?

    I am stuck. I can not figure out how to get the microsoft office that is on my (admin) profile dock onto the dock for the other users on my mac. Can anyone help me out?

    ebony --
    So, when you open your main Applications folder, there is no Office app there?
    It's in your Users>Applications folder?

  • IPhoto:  How can I sort photos within an event?  I can't figure out how to activate the Manual Sort.

    iPhoto:  How can I sort photos within an event.  I can't figure out how to activate the Manual Sort button.

    Only albums can be sorted manually. Events can only be sorted automatically according to one of the predefined settings "Date, Keywords, Title, Rating".
    If you need a manual sort order, selectaall photos in the event and create an album: File > New Album

  • The window displaying bookmarks is too large (suddenly happened with the new version). I can't figure out how to make the display smaller. Zooming out does not work on the bookmark menu display.

    I have version 4, just downloaded, and a Mac w. OS 10.6. 7.
    The bookmarks display (when I pull down "bookmarks") is much too wide. I can't figure out how to reduce the display size. The window is not persistent so I can't even get you a screen shot.
    Thanks, Sara

    It seems there was a change in Firefox 4 where the width of the drop-down is now determined by the length the longest bookmark name in the folder being displayed. Previous versions of Firefox would shorten a long name like that and add an ellipsis to signify the name was truncated.
    Sorry, I don't know how to change that other than to advise you to edit the name of that long bookmark name and make it less verbose. Just scroll down the list of bookmarks in that wide folder until you see the culprit, then right-click that bookmark and open Properties & edit the Name line at the top of that dialog.

  • IPhone 5S IOS 8. Can't figure out how to disable the "live" location feature within the native calendar app used for mapping/travel time.  Have looked everywhere and it's driving me nuts.  Thanks for any help on where to make the change!!

    iPhone 5S IOS 8. Can't figure out how to disable the "live" location feature within the native calendar app used for mapping/travel time etc.  Have looked everywhere and it's driving me nuts.  Thanks for any help on where to make the change!!

    iPhone 5S IOS 8. Can't figure out how to disable the "live" location feature within the native calendar app used for mapping/travel time etc.  Have looked everywhere and it's driving me nuts.  Thanks for any help on where to make the change!!

  • Hi. I just downloaded "angry birds" from the iTunes store. It says it was successfully downloaded and that I can use it on the two mac products I have. I can see an icon for it in the finder on the mac, but I can't figure out how to play the game. Anyone?

    Hi. I just downloaded "angry birds" from the iTunes store. It says it was successfully downloaded and that I can use it on the two mac products I have. I can see an icon for it in the finder on the mac, but I can't figure out how to play the game. Anyone?

    Thank you for your reply. After a lot of fruitless searches, I hit on a page that offered the same wisdom you did. I feel like rather a fool for not knowing that. Grr. I really appreciate your answer, and that you didn't end it with "dummy." Cheers to you. Hope someone does something kind for you today.

  • Macbook:  How do I uninstall a game on the macbook?  I need to reinstall the game for it to work, but I can't figure out how to uninstall the game to begin with.

    I need to reinstall the game for it to work, but I can't figure out how to uninstall the game to begin with.  I know that in Windows, there is an "Uninstall" option, but I have found no such option on the Macbook.

    This is one OS X's few weak spots. For most software, it is sufficient to drag the application out of the Applications folder and into the trash.  Of course, this does not delete its preference files, etc, but these are usually pretty small, and can either be left in place or deleted separately.
    Some software might ship with a separate uninstaller utility that you can run.  Sometimes, the package installer can also perform uninstalling, too. 
    You can buy general purpose uninstaller utilities, but as far as I know they won't work for software already installed; only for software installed once the uninstaller is in place.
    Perhaps the safest option is to contact the company that made the game and ask them how it should be uninstalled. 
    Bob

  • Now I can't figure out how to assign the new tones to my contacts

    I used the option "buy more" under ringtones on my iphone 5S.  Now I can't figure out how to assign the new tones to my contacts. Help please!

    Hello p618cg,
    Congratulations on your new iPhone 5s!  You can follow these steps to assign a ringtone to a contact:
    Set a special ringtone for a contact.
    In Contacts, choose a contact, tap Edit, then tap Ringtone. Select the ringtone you'd like to hear when that person calls.
    iPhone Basics - Set a special ringtone for a contact
    http://support.apple.com/kb/TI16
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

Maybe you are looking for

  • How can you enable back the Android native Menu button in AIR 2.7?

    I've noticed in AIR 2.7 for Android, that now the bottom icons in Android 3.0 Honeycomb are hidden (replaced by small dots) in AIR 2.7, whereas in AIR 2.6 they were always visible. That's cool. Since the bottom bar can never be hidden in Android 3, a

  • How to get the long description of a lineitem

    Hi,      I am able to get the description of a line item present in Master Agreement by following code. lineItemCollection = agreementBean.getLineItems(); collectionsize = lineItemCollection.size(); collectionbean = lineItemCollection.get(0); type =

  • CUC Cluster not functioning correctly

    Saw a few posts and documents relating to this issue but they don't match up perfectly with my particular scenario.  Basically, the customer could no longer log into the Unity Pub so we had to do a rebuild as nothing was working.  The sub took over a

  • I can't get this to paint.

    Hi, I am trying to get this create a new panel. And in that panel, I am trying to have some credits paint. I have not been able to get this to do anything more than give me an error (java.lang.NoSuchMethodError: main Exception in thread "main" ) or w

  • How can i install Nikon Capture NX2 on osx 10.7.4

    having trouble installing the software names above.... help