Stupid questions about float operation

Hi guys.
I have this code:
public class Stupida{
     public static void main(String args[]){
          float uno = 14.8210f;
          float due = 14.7110f;
          System.out.println("" + uno + " - " + due + " = " + (uno-due));
and this is the output:
14.821 - 14.711 = 0.10999966
Why the result it's not 0.110????
I tried with double, but the problem's the same.
I tried to use the "strictfp" modifier, but the compiler doesn't recognize it.
What should I do to get the exact result?
Thanx,
Pierlu.

and this is the output:
14.821 - 14.711 = 0.10999966
Why the result it's not 0.110????Because floating-point calcuations are inherently imprecise.
I tried with double, but the problem's the same.If you use double, the answer should be more accurate - you still can not expect it to be precise.
I tried to use the "strictfp" modifier, but the
compiler doesn't recognize it.Then you should get a new compiler.
Even so, the result you have posted is what I got using the strictfp modifier.
What should I do to get the exact result?I'm not going to go into detail because there are many threads in the forums that already cover this, and there's plently of good technical explainations on the Web - you just have to do a couple of simple searches.
In short, there are a couple of ways to get correct results. The safest is to use BigDecimal. Another (faster) option is to perform all your calculations using int or long, and keep track of where the decimal point should be, then add it in afterwards for display purposes (however, this requires a prior knowledge of a bounding range in which the figures you are operating on lie).

Similar Messages

  • Stupid question about atomic operations

    Why there are separate atomic classes? Why not make all primitive operations atomic? Is this a performance issue?

    Currently, I'm readin this:
    http://www.oreilly.com/catalog/jthreads3/chapter/ch05.
    pdf . It says that, for example, ++ operation is not
    atomic.++ by nature is a 3 step process--read, add, write. I suppose it would have been technically possible to make that an atomic operation, but it probably would have involved complicating the JLS and JMM, and possibly hurting overall performance of all operations.

  • Probably a stupid question about cropping a video..

    OK, so I shot an interview with a black background and once I went to edit it, I noticed a red object in the far right corner. Is there a way I can add black over this object or crop it out? I know this is a stupid question, but I'm new to video and editing in general so I thought it wouldn't hurt to ask.

    There are several ways to accomplish what you want.
    KGCW has talked about the Crop Effect.
    Depending on exactly where the object is, and whether the camera was locked down, it might be possible to duplicate your Clip, place it above your initial Clip, then offset it a bit (Motion>Position), with the Fixed Effect>Motion>Position, and then apply the Garbage Matte to that offset duplicate, effectively Cropping out everything, but a small "patch" from the existing background. Note: if the edges of that Garbage Matte are too hard for you, you could create a soft-edged Track Matte, and use that to hold out the rest of the offset duplicate.
    Another method, and depending on where, and how large the offending item is, would be to go to the Fixed Effect>Motion, and use Motion>Scale to increase the size of the Clip (do not do too much Scale, or quality will suffer). You might also need to do a bit of Motion>Position, to get that red object behind the Video's Frame Size. This will effectively Crop the object.
    Good luck,
    Hunt

  • A very stupid question about MDic application[SOLVED]

    I have tried StarDict in Arch which I think that is the best known dictionary application in Linux world. Since I had to use mouse to access StarDict, I decided to try MDic instead. My problems is that I do not know the default location of MDic dictionary files. After search topics for about two hours, I gave up.
    There must be a directory where MDic searches for dictionary files. Where is it? or What MDic configuration file has the information? So, I can install dictionary files int to the directory. I looked for this information in http://mdic.gnufolks.org/ and google.com. I believe this kind of very fundamental information should be in the wiki fo MDic. But I couldn't find one. Maybe, it is because I am so idiot. Would somebody help me how to install MDic dictionary in a appropriate location or the default location? Thank you so much for your helps.
    Last edited by since1992 (2010-11-06 11:28:30)

    Yes, it was a stupid question. I found that I can configure the location of the dictionary file. I also installed PyGlossary to convert dictionaries for MDic. Everything works fine now. Thank you.

  • Probably a stupid question about upgrades...

    I originally bought Adobe CS3 Web Premium and upgraded to CS5.5 Design Premium last year.  I'm wondering if I upgrade, will my price be based on the CS3 license or the CS5.5 upgrade...?
    I'm guessing it will be based on CS5.5, but I want to make sure.
    -A. Ka

    There are no stupid questions!
    Regardless of whether you got to CS5.5 via upgrading to it or by originally licensing CS5.5 is irrelevant in terms of the upgrade price to CS6 as well as the media you use for the upgrade.
              - Dov

  • Stupid questions about keeping important calls on the FX application thread

    I'm working on a project that I've been developing for about the last 6 months. I'm using JavaFX as the graphical side, but I'm taking input from a music processing program called Max/MSP, and I'm getting user input from a camera. Both of these things need to run on separate threads from my FX application thread. Up until now, things have been going smoothly. I can manipulate things on screen from my user input, and I have two way communication working between my JavaFX application and Max. Now, however, I need to start actually drawing stuff at runtime. Up until now, pretty much all FX side manipulations of been to just make translations. I now need to create, add, and remove children from Nodes. So I'm of course getting an error saying "not on FX application thread". I understand why it isn't on this thread, and why this is a problem. So I made some changes, so that calls that will make changes to the nodes on the stage, will only note the data, and then make the changes later, on the FX application thread. And then I run into problems, involving my own stupidity...
    I have no idea how to get these calls onto the FX application thread. I mean, this should be really easy. I'm obviously missing something. Or maybe I'm just really tired, and have been looking at this for too long, or maybe the fact that it's been 6 months since I wrote this part of the code. But I see my Mainstage class, which extends Application. It has a start function, which sets up all my on screen do-dads (extended from Nodes and such), calls stage.show()... and then seems to end. When I've done things like call translate functions on my nodes from my user input thread, or from my communication from Max thread, things seemed to have worked. But now I'm thinking I might have been handling that wrong from the ground up. It seems likely that I should be having a "main game loop" (it isn't actually a game, but still, same principle) where I can tell the stage to update all the various nodes with the changes that have happened since the last frame, and try to get everything to update in time for the graphics to render at a reliable frame rate. And yet, I'm just not seeing how to do that. I'm sure this should be obvious, but I'm flat out blanking. And the time crunch is starting to descend... Please, if you can point out some standard way of avoiding this hopefully common newb mistake, I would greatly appreciate it!
    -cullam

    Checkout the documentation on "Pulse" in the JavaFX Archictecture overview which may help clarify some of your questions.
    http://docs.oracle.com/javafx/2.0/architecture/jfxpub-architecture.htm
    In simple terms, as I understand it, the framework will check 60 times a second if anything is dirty and needs repainting. If everything is clean, it will do nothing. If something is dirty, it will repaint it (although the repaint is kind of clever and highly optimized to support region image caching, make use of hardware rendering, etc).
    So you can see that the main rendering loop is essentially hidden from you. Instead you construct a SceneGraph, the system checks regularly whether or not the SceneGraph has changed, and if it has it renders the updated SceneGraph.
    In most JavaFX applications, you have a UI with controls and add event handlers which respond to control input to update the SceneGraph. In such programs, creating a main loop is unnecessary.
    You can set up an animation timeline say at, for example, 30fps (half the pulse rate), then, on every other pulse, nothing will have changed so no redraw will happen. This is only necessary if you are performing an animation or capturing camera input, etc yourself (rather than using a Transition for example).
    Actually, if I get my state changes working properly in a runLater call, do I need to also write a main loop? No, you don't need to write a main loop. Depending on the exact application, you may want one, but if you are already getting events generated by your camera input at 30fps, processing each 30fps from the camera in a runLater call would work fine without creating a loop.
    But you do need to be careful that you don't send too many runLater calls and eventually overload the JavaFX event queue. For example it makes no sense to make more than 60 runLater calls a second to update the scene, because the system will never update the scene more than 60 times a second anyway.
    If you do get a working camera app integrated with JavaFX, please post or blog about it as I am sure many people are interested in such an application.

  • Question about bit operation

    1/ I know I can use << to translate from number of index to the binary number.
    But how can I translate from binary number to number of index? (e.g. 1024 translates to 10)
    2/ How can I separate two bits in a number? (e.g. 144 translates to 128+16)
    3/ How can I know that the number exists a required bit? (e.g. check 144 if there exists 4th bit)
    Currently, I translate to binary number string first and then use indexOf and lastIndexOf methods to get the location of the bits.
    3rd question I use number==(number|10000)
    Is it any other more efficient methods to achieve that?
    Thanks.

    nwoedf wrote:
    1/ I know I can use << to translate from number of index to the binary number.
    But how can I translate from binary number to number of index? (e.g. 1024 translates to 10)Convert the number to a binary String and go through it keeping track of the 1 bit positions.
    You can use Integer.toString(1024, 2); to convert for example.
    2/ How can I separate two bits in a number? (e.g. 144 translates to 128+16)Same as the first one, then you just need to go through the bits again and translate the indices into the values.
    3/ How can I know that the number exists a required bit? (e.g. check 144 if there exists 4th bit)The & operator can be used for that for example.
    Currently, I translate to binary number string first and then use indexOf and lastIndexOf methods to get the location of the bits.
    3rd question I use number==(number|10000)
    Is it any other more efficient methods to achieve that?Why, is your computer not doing this fast enough?

  • Questions about Deployment Operations Manager 2012 R2

    Hi Folks
    Questions: I have one infrastructure with Operations Manager 2012 R2, two Management Server.
    Now, I'm trying install feature operations manager reporting in SQL Server.
    added the OMDRA and OMDWWA accounts as a local administrator of the SQL server.
    I'm using media installation Operations Manager 2012 R2, but I'm received erros, any idea? Or I need using media installation Operations Manager 2012 SP1?
    Thanks
    Wilsterman Fernandes

    Hi There,
    I had seen a similar issue here. The error log has a point mentioning " ApplyUpdates: Unable to load QFE file."
    I saw this error on this below thread as well.
    https://social.technet.microsoft.com/Forums/en-US/a10ce69e-2584-4a4d-86b9-64ee8c5bf85d/reporting-services-installation-failing?forum=operationsmanagerreporting
    He said he fully re installed the whole setup and it solved the issue.
    But i understand that is quiet difficult and complicated to do.
    =================================================
    I would suggest you check the permissions again
    1.Does your data reader and writer account have SQL permissions i.e sysadmin permissions ?
    2.Also is your SQL server in the same AD Domain or is it in a different domain ?
    3.Is the SQL Server scale of deployment joined ?
    4. Did you look in the ops manager event logs ? Can you check and post them here plz.
    5. Is the operationsmanager DB and warehouse DB as well hosted on the same SQL server where you are trying to install reporting.
    Gautam.75801

  • Question about KDM Operation

    Hi Gurus,
    I have the following issue with KDM operation while posting invoice document in MIRO t-code:
    I have a PO where value is  EUR 100 currency, then I did the Goods Receipt and then the invoice entry in MIRO also in EUR but instead of EUR100 I enter EUR130.  After posting I display the account document in USD instead of EUR and in some cases I find that all the difference is charge in a KDM account and in others in PRD operation. The exchange rate varies between the goods receipt in MIGO and the invoice entry in MIRO.
    my question is why in some cases all the difference is charge in KDM and in others examples with the same values, same material/plant, same currency and same exchange rate variation the difference is sent to a PRD account and nothing to KDM.....
    PLease advice....
    Thanks

    Hello,
    This issue was solved.
    PRD appears always when there is a difference value enters in MIRO in comparison with the goods receipt, independent of the reason. KDM, instead where there is a variation in the rate exchange between the goods receipt and the invoice registration in MIRO, when the value is equal, minor or higher than the value entered in MIGO up to the equivalent in the conversion currency . Higher than this value only PRD appears.
    Hope this will be useful for anyone of you!

  • Basic (probably stupid) question about APExp

    Hi, Just one quick question. The Wi-Fi connection provided by the built in airport in my iMac covers my whole living room, but since I have many apple devices using that same NetWork, sometimes it fails. So before I buy an aiport extreme, I would like to try the airport express, and my question is: The airport express connects (and amplifies) to the wi-fi network of the iMac, so how do I know on which airport am I connecting with my other apple devices? I don't know if I was able to be clear. Thanks a lot!

    Just one more question. If the APExp creates a new wifi network how do I have internet in all The devices?
    Is it possible the following network configuration?:
    iMac - cable - modem ( existing already) - existing AirPort - AirPort express - wifi (with internet) for all the other devices ( iPhone, apple tv, MacBook, ps3 )?
    My idea is to have all this devices in network ( sharing files, playlists) with internet access ( which is phisically connected to The iMac)
    Is it possible? Or do I have to buy an AirPort extreme AND an AirPort express ( since I have to have a cable To my ps3...And my wife is bugging me about The LAN cable across The living room?) . Thanks

  • Question about Processors, Operating Systems and TFLOPS

    Hi guys, I recently read an article about the power of the PS3 consoles. This is a table that I copied from it, which I don't really undestand. All I can see is that the Mac OSX shows the least number of TFLOPs for both PowerPC and Intel architectures. That doesn't seem to be good. If there's anyone out there who can translate the details into "basic language" I would appreciate it.
    OS Type------------Current TFLOPS----Active CPUs---Total CPUs
    Windows------------152--------------159564------1625622
    Mac OS X/PowerPC------7----------------8737--------95371
    Mac OS X/Intel---------9----------------2756----------7272
    Linux----------------43---------------25126-------215901
    GPU-----------------42-----------------708----------2199
    PLAYSTATION®3-----516---------------21062---------22299
    ==============================================
    Total----------------769--------------217953-------1968664
    If you are further interested, or the table became unreadable, or both, this is the link to the original article.
    Thank you very much in advance.
    George...
    MBP 15in 2.33GHz.   Mac OS X (10.4.9)   other 200+ posts with the old Discussion Forums (now lost)

    Yes, you are misinterpreting the data.
    What you're looking at is the workload on some distributed computing task like folding@home, right?
    What it's telling you is that at the time you checked, Windows computers were contributing 152 TFLOPs (trillions of operations per second), PowerPC-based Macs contributed 7, Intel-based Macs added 9, and 516 from the PS3.
    However, you also need to take into account the number of active machines.
    Those 152 Windows TFLOPS were the combined output of 159,564 CPUs, for an average of 0.0009525958 TFLOPS/CPU.
    By comparison, the 7 PowerPC TFLOPS were from 8737 CPUs, or 0..0008011903 TFLOPS/CPU - not all that much different and statistically insignificant.
    The Intel Macs' 9 TFLOPS from 2756 CPUs equates to 0.0032656023 TFLOPS/CPU - significantly higher than either of the other two results.
    The PS3 on the other hand contributes 516 TFLOPS from 21062 CPUs, for 0.0244990979 TFLOPS/CPU - an order of magnitude higher still.
    I'd take the results with a large pinch of salt, though - is that 7 TFLOPS for the PowerPCs, 6.5, or 7.49? That makes a big difference.
    Also, consider that when the PS3 is running the code, that's all its doing. Any other OS is going to be running other applications at the same time.
    Don't get me wrong, the Cell processor is certainly pulling its weight, but don't discard the GPU - its 42 TFLOPS come from just 708 CPUs, for an average of 0.0593220338 TFLOPs/CPU - two and a half times that of the PS3.

  • Probably a stupid question about Date

    Hi.
    I am struggeling with something that should be an easy task, but I can't seem to get it right.
    I want to extract a date from a view object, add a number of days to the date, and compare it with todays date.
    This is what I try to do:
    Date today = (Date)oracle.jbo.domain.Date.getCurrentDate();
    Date published = null;
    int days = currThing.getExpirenumber().intValue();
    expires = currThing.getPublishdate();
    expires.addJulianDays(days,0);
    switch (expires.compareTo(today)){
    case -1: return true;
    case 0: return true;
    case 1: return false;
    his code compiles, but when I run it I get an java.sql.SQLException: Unimplemented method called
    What am I doing wrong here ??
    Is there another way to do this ?
    Morten
    null

    There are several ways to accomplish what you want.
    KGCW has talked about the Crop Effect.
    Depending on exactly where the object is, and whether the camera was locked down, it might be possible to duplicate your Clip, place it above your initial Clip, then offset it a bit (Motion>Position), with the Fixed Effect>Motion>Position, and then apply the Garbage Matte to that offset duplicate, effectively Cropping out everything, but a small "patch" from the existing background. Note: if the edges of that Garbage Matte are too hard for you, you could create a soft-edged Track Matte, and use that to hold out the rest of the offset duplicate.
    Another method, and depending on where, and how large the offending item is, would be to go to the Fixed Effect>Motion, and use Motion>Scale to increase the size of the Clip (do not do too much Scale, or quality will suffer). You might also need to do a bit of Motion>Position, to get that red object behind the Video's Frame Size. This will effectively Crop the object.
    Good luck,
    Hunt

  • A stupid question about the new mac pro

    I know the mac pro has dual ethernet ports, but does it also have wifi built in? Or do I actually have to plug it tonto my router? Sorry for the perhaps obvious question.
    PS. As a point of interest, I received mine yesterday. There was NOTHING inside of the box except for the cpu. I know the docs will be already installed on the cpu along with my purchase of Final Effex Pro X. It just took me by surprise is all. Now my next problem is trying to take my time and relish the exciting setup today. Unfortunately, I have compression fractures in my lower back from this last snow storm, so my enjoyment will be bitter sweet.
    Thanks for you help.
    ---jerry

    From the product page (http://www.apple.com/mac-pro/specs/):
    Wireless: 802.11ac Wi-Fi wireless networking;3 IEEE 802.11a/b/g/n compatible
    and
    In the box: Mac Pro, power cord
    So, yes, it does have Wi-Fi. However, you are likely to get better local network performance with a gigabit ethernet cable and a gigabit ethernet switch (assuming you have other local gigabit devices similarly connected).
    For many years, Apple has been cutting down on the amount of hardcopy documentation shipped with products. Two years ago, my MacBook Pro came with a tiny booklet that was little more than how to plug it in and turn it on, an equally tiny warranty booklet, and some logo stickers. I'm only a little surprised to hear they are now down to zero paper shipped.

  • Stupid question about "What's in the box?"

    Ok, i just got my new iPod Touch 32GB. I'm really confused about one of the items that came in the box.
    This one thing that looks like an insert for the dock - the shape of it is too wide for the skinny little iTouch - and it's only a dock insert, it's not the dock itself.
    So i'm confused - how do i make use of this? I tried clipping it on my iPhone dock, & my 4th. Generation iPod dock, as well as my iHome alarm clock dock - and it doesn't fit anywhere.
    It does not lay flat, it doesn't fit anything, and i am really confused. Does anybody know what i am to do with this? Thank you.
    Jason

    It's a dock adapter for docks that use the Apple system, such as Apple's own. You'd put it in the dock so your iPod would fit properly. iHome uses it's own adapater system. Honestly, I hardly ever find a use for them as I don't use docks much. I think I have a box of them somewhere from all the iPods I've purchased...

  • 6280 stupid question about camera

    Hi
    I've just bought a 6280 phone and know very little about new phones. Could someone please tell me what the checkerboard indicator is on the left of the screen when I use the camera. Thanks very much, Lisa

    Thanks Gun for the answer,
    This transaction type shows the Organization tab in GUI environment (the settings related to org profile are correctly customized). The problem is in webclient. When I try to create this transaction type in webclient, the only sections which I can fill are:
    General Data
    Texts
    Partners
    But the others tab are missing in screen.
    I created a transaction from IC web and then in GUI environment the tab Organization is correctly filled and the tab is shown. But, what if I want to change the automatic determination in web environment?
    Regards
    Javier Merino
    Message was edited by:
            Javier Merino Vivar

Maybe you are looking for

  • I need to divide a large 111MB PDF

    I need to divide a large 111MB PDF into several smaller more manageable pieces. I have CS5 but it won't open it. I just bought PDF Extractor so I could convert it to a Microsoft Word File and edit from there. Message says, file too big, over 100MB. H

  • SYSTEM HANGS WHILE RUNNING EXP COMMAND IN ORACLE 10G

    WHEN WE ARE RUNNING THE EXP (EXPORT) COMMAND IN ORACLE 10G TO TAKE THE BACKUP IT GETS HANGED FOR A LONG TIME AND THEN IN THE LOG FILE WE FIND THE FOLLOWING ERROR MESSAGE. SOMETIMES AFTER RESTARTING THE SERVER WE ARE ABLE TO RUN THE EXP COMMAND. Conne

  • Error connecting to PTG repo using service designer.

    I am trying to login into my ptg repousing service designer but have problems.i have install 9ias on a different server and my db on server. this is the message i get back. oracle.panama.pasm.PASMException: Exception creating connection to: ERIC; nes

  • Do any instances of RGB get converted to CMYK on output to PDF?

    Hi, I'm producing a HUGE catalogue that I've inherited from another designer. It will be going to print soon and I'll be providing the printers with a press ready PDF. The catalogue contains hundreds of individual blocks of colour (used to show colou

  • TDS should deduct 20% when PAN number not mainted of Vendor

    Hi, According to gov. norms, if Vendor Have PAN Number, then TDS must deduct 10%. But if Vendor don't have then it should be deduct 20% TDS Amount. Please guide me, how can we configure it.. Regards..