Search Results

Search found 1065 results on 43 pages for 'calculation'.

Page 7/43 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Calculations coming out to 0.0?

    - by Nick Gibson
    A simple percentage calculation. It wont return a value except 0.0 and I think once or twice it returned 100.0%. Other than that it won't do a thing. I have tried playing with the code in several different ways and it just wont work. for (int loop = 1; loop < loopCount; loop++) { aa = r.nextInt(10+1); abc = (int) aa; String[] userAnswer = new String[x]; int totalQues = (correctAnswer + wrongAnswer), actualQues = (totalQues - 1); if(abc < x) { userAnswer[abc] = JOptionPane.showInputDialog(null,"Question "+quesNum+"\n\n"+questions[abc]+"\n\nA: "+a[abc]+"\nB: "+b[abc]+"\nC: "+c[abc]+"\nD: "+d[abc]+"\nCorrect Answers: "+correctAnswer+"\nWrong Answers: "+wrongAnswer+"\nTotal Questions: "+totalQues); if(userAnswer[abc].equals(answers[abc])) { correctAnswer++; } else { wrongAnswer++; }//else if(actualQues == x); { score = (correctAnswer / actualQues) * 100; JOptionPane.showMessageDialog(null,"The test is finished."); JOptionPane.showMessageDialog(null,"You scored "+score+"%"); }//if }//if }//for

    Read the article

  • How can I set PivotField.Calculation in Excel/VSTO?

    - by Kang Su
    I'm trying to set the Calculation property on an OLAP PivotField with VSTO 3.0. For example: pivotField.Calculation = XlPivotFieldCalculation.PercentOf; If I do the above, the value I assign does not stay (Excel appears to revert the change). I suspect the reason is that the BaseField property of the PivotField also needs to be populated (as PercentOf needs a BaseField). But it appears to me that you can't set the BaseField property until you've set the Calculation property (otherwise you get a COMException). I've tried to set ManualUpdate on the PivotTable to true, but with VSTO this rarely works, as this gets reverted immediately back to false. Note, that this seems to work fine in VBA as you can assign multiple values in a single statement, like this: With ActiveSheet.PivotTables("PivotTable1").PivotFields("[Measures].[Reseller Sales Amount]") .Calculation = xlPercentOf .BaseField = "[Geography].[Geography].[Country]" .BaseItem = "[Geography].[Geography].[Country].&[France]" .NumberFormat = "0.00%" End With But with C#/VSTO there's no construct like this (that I know of) and I'm stuck not able to do something like the above. Further note, Calculation values that don't require a BaseField, e.g., XlPivotFieldCalculation.xlPercentOfTotal, get set just fine. Any help on this would be greatly appreciated!

    Read the article

  • Japanese Multiplication simulation - is a program actually capable of improving calculation speed?

    - by jt0dd
    On SuperUser, I asked a (possibly silly) question about processors using mathematical shortcuts and would like to have a look at the possibility at the software application of that concept. I'd like to write a simulation of Japanese Multiplication to get benchmarks on large calculations utilizing the shortcut vs traditional CPU multiplication. I'm curious as to whether it makes sense to try this. My Question: I'd like to know whether or not a software math shortcut, as described above is actually a shortcut at all. This is a question of programming concept. By utilizing the simulation of Japanese Multiplication, is a program actually capable of improving calculation speed? Or am I doomed from the start? The answer to this question isn't required to determine whether or not the experiment will succeed, but rather whether or not it's logically possible for such a thing to occur in any program, using this concept as an example. My theory is that since addition is computed faster than multiplication, a simulation of Japanese multiplication may actually allow a program to multiply (large) numbers faster than the CPU arithmetic unit can. I think this would be a very interesting finding, if it proves to be true. If, in the multiplication of numbers of any immense size, the shortcut were to calculate the result via less instructions (or faster) than traditional ALU multiplication, I would consider the experiment a success.

    Read the article

  • Need help programming with Mclauren series and Taylor series!

    - by user352258
    Ok so here's what i have so far: #include <stdio.h> #include <math.h> //#define PI 3.14159 int factorial(int n){ if(n <= 1) return(1); else return(n * factorial(n-1)); } void McLaurin(float pi){ int factorial(int); float x = 42*pi/180; int i, val=0, sign; for(i=1, sign=-1; i<11; i+=2){ sign *= -1; // alternate sign of cos(0) which is 1 val += (sign*(pow(x, i)) / factorial(i)); } printf("\nMcLaurin of 42 = %d\n", val); } void Taylor(float pi){ int factorial(int); float x; int i; float val=0.00, sign; float a = pi/3; printf("Enter x in degrees:\n"); scanf("%f", &x); x=x*pi/180.0; printf("%f",x); for(i=0, sign=-1.0; i<2; i++){ if(i%2==1) sign *= -1.0; // alternate sign of cos(0) which is 1 printf("%f",sign); if(i%2==1) val += (sign*sin(a)*(pow(x-a, i)) / factorial(i)); else val += (sign*cos(a)*(pow(x-a, i)) / factorial(i)); printf("%d",factorial(i)); } printf("\nTaylor of sin(%g degrees) = %d\n", (x*180.0)/pi, val); } main(){ float pi=3.14159; void McLaurin(float); void Taylor(float); McLaurin(pi); Taylor(pi); } and here's the output: McLaurin of 42 = 0 Enter x in degrees: 42 0.733038-1.00000011.0000001 Taylor of sin(42 degrees) = -1073741824 I suspect the reason for these outrageous numbers goes with the fact that I mixed up my floats and ints? But i just cant figure it out...!! Maybe its a math thing, but its never been a strength of mine let alone program with calculus. Also the Mclaurin fails, how does it equal zero? WTF! Please help correct my noobish code. I am still a beginner...

    Read the article

  • how to calculate a bill from several tables on mysql?

    - by Audel
    I'm using mysql to create an hotel booking system, but i am struggling a little bit to calculate the final bill. I need a SELECT command to get data from several tables and make some calculations. Basically I just need to get the 'night cost' from a table called 'room_types'. Then, use DATEDIFF function to get the difference of days between the 'checkin' and 'checkout' columns in the table 'room_booking' and multiply the difference with the night cost and display the total. These are the tables I would be using: are room_booking, room_types, booking, and room. One booking may have several room bookings, so Im looking for a table that looks something like this: +------------+------------+---------------+------------------+ | bookingid | Room price | nights stayed | total room price | +------------+------------+---------------+------------------+ | B001 | 30.00 | 4 | 120.00 | +------------+------------+---------------+------------------+ | B001 | 40.00 | 3 | 120.00 | +------------+------------+---------------+------------------+ booking id comes from table 'booking' room price from 'room_types', 'nights stayed' is calculated from the table room_booking, using the datediff command between checkin and checkout . I hope i was clear

    Read the article

  • Need to add totals of select list, and subtract if taken away

    - by jeremy
    This is the code I am using to calculate the sum of two values (example below) http://www.healthybrighton.co.uk/wse/node/1841 This works to a degree. It will add the two together but only if #edit-submitted-test is selected first, and even then it will show NaN until I select #edit-submitted-test-1. I want it to calculate the sum of the fields and show the amount live, i.e. the value of edit-submitted-test-1 will show 500, then if i select another field it will update to 1000. If i take one selection away it will then subtract it and will be back to 500. Any ideas would be helpful thanks! Drupal.behaviors.bookingForm = function (context) { // some debugging here, remove when you're finished console.log('[bookingForm] started.'); // get number of travelers and multiply it by 100 function recalculateTotal() { var count = $('#edit-submitted-test').val(); count = parseFloat( count ); var cost = $('#edit-submitted-test-1').val(); cost = parseFloat( cost ); $('#edit-submitted-total').val( count + cost ); } // run recalculateTotal every time user enters a new value var fieldCount = $('#edit-submitted-test'); var fieldCount = $('#edit-submitted-test-1'); fieldCount.change( recalculateTotal ); // etc ... }; EDIT This is all working beautiful, however I now want to add all the values together, and automatically update a total cost field that is the sum of a the added field with code above and field with value passed from previous page. I did this where accomcost is the field that is added together, but the total cost field does update, but not automatically, it is always one selection behind. i.e. If i select options and accomodation cost updates to £900, total cost remains empty. If i then change the selection and the accomodation updates to £300, the total cost updates to the previous selection of £900. Any help on this one Felix? ;) thanks. var accomcost = $('#edit-submitted-accomodation-cost').val(); accomcost = accomcost ? parseFloat(accomcost) : 0; var coursescost = $('#edit-submitted-courses-cost-2').val(); coursescost = coursescost ? parseFloat(coursescost) : 0; $('#edit-submitted-accomodation-cost').val( w1 + w2 + w3 + w4 + w5 + w6 + w7 + w8 + w9 + w10 + w11 + w12 + w13 + w14 + w15 + w16 + w17 + w18 + w19 + w20 + w21 + w22 + w23 + w24 + w25 + w26 + w27 + w28 + w29 + w30 ); $('#edit-submitted-total-cost').val( accomcost + coursescost ); var fieldCount = $('#edit-submitted-accomodation-cost, #edit-submitted-courses-cost-2') .change( recalculateTotal );

    Read the article

  • Howto project a planar polygon on a plane in 3d-space

    - by sum1stolemyname
    I want to project my Polygon along a vector to a plane in 3d Space. I would preferably use a single transformation matrix to do this, but I don't know how to build a matrix of this kind. Given the plane's parameters (ax+by+cz+d), the world coordinates of my Polygon. As stated in the the headline, all vertices of my polygon lie in another plane. the direction vector along which to project my Polygon (currently the polygon's plane's normal vector) goal -a 4x4 transformation matrix which performs the required projection, or some insight on how to construct one myself

    Read the article

  • Algorithm for deciding price ranges.

    - by Paul Knopf
    I am looking for code that will take a huge list of numbers, and calculate price ranges correctly. There must be some algorithm that will choose the proper ranges, no? I am looking for this code in c#, but any language will do (I can convert). Thanks in advance!

    Read the article

  • C - floating point rounding

    - by hatorade
    I'm trying to understand how floating point numbers work. I think I'd like to test out what I know / need to learn by evaluating the following: I would like to find the smallest x such that x + 1 = x, where x is a floating point number. As I understand it, this would happen in the case where x is large enough so that x + 1 is closer to x than the next number higher than x representable by floating point. So intuitively it seems it would be the case where I don't have enough digits in the significand. Would this number x then be the number where the significand is all 1's. But then I can't seem to figure out what the exponent would have to be. Obviously it would have to be big (relative to 10^0, anyway).

    Read the article

  • Custom Calculations in a Matrix - Reporting Services 2005

    - by bfrancis
    I am writing a report to show gas usage (in gallons) used by each department. The request is to view each month and the gallons used by each department. A column is required to display what each departments target goal is, based on the gallons of gas they have used in a past time frame. Each departments target goal is x percent less than the total gallons used for said time frame. I currently have a matrix in Reporting Services with departments making up rows, months making up columns, and gallons filling the details. The matrix is being filled by dataset1. I have the data grouping as is requested for each month by each department. My problem is calculating the target goal. My thought was to create a second dataset (dataset2) that returns the gallons used based on the time frame requested. I grouped this data by department. I was hoping I could use the department field in each dataset to make sure the appropriate numbers were used. I added a new column which shows up next to the gallons field. As I attempted to build the Expression I found out that I could only grab the gallons used from dataset2 if I was summing the gallons field. This gives me the total gallons used by every department combined. I have tried to find resources with similar examples of what I am trying to accomplish but I cannot seem to come across one. I am trying to keep this as detailed as possible without making it too wordy. I would be more than happy to clarify or explain into further detail what I have written above if it is needed. If anyone has links, comments, or suggestions they would be greatly appreciated. A very simple visual or what I am hoping to accomplish is below. The months and departments would expand based on the data returned. months ------------------------------ departments| gallons/month | target goal

    Read the article

  • Why does this JavaScript not correctly update input values?

    - by dmanexe
    I have two input fields, and without changing their names (i.e., I have to use the name with the brackets), how do I make this javascript code work? <script> function calc_concreteprice(mainform) { var oprice; var ototal; oprice = (eval(mainform.'estimate[concrete][sqft]'.value) * eval(mainform.'estimate[concrete][price]'.value)); ototal = (oprice); mainform.'estimate[concrete][quick_total]'.value = ototal; } </script> Here's the HTML of the input area. <tr> <td>Concrete Base Price</td> <td><input type="text" name="concrete[concrete][price]" value="" class="item_mult" onBlur="calc_concreteprice(document.forms.mainform);" /> per SF <strong>times</strong> <input type="text" name="concrete[concrete][sqft]" value="" class="item_mult" onBlur="calc_concreteprice(document.forms.mainform);" /> SF</td> <td> = <input type="text" name="concrete[concrete][quick_total]" value="" /></td> </tr> I know I can get it working by changing_the_input_name_with_underscores but I need to have the names with the brackets (storing the form contents in an array).

    Read the article

  • How to give a textbox a fixed width of 17,5 cm?

    - by Natrium
    I have an application with a textbox, and the width of the textbox on the screen must always be 17,5 centimeters on the screen of the user. This is what I tried so far: const double centimeter = 17.5; // the width I need const double inches = centimeter * 0.393700787; // convert centimeter to inches float dpi = GetDpiX(); // get the dpi. 96 in my case. var pixels = dpi*inches; // this should give me the amount of pixels textbox1.Width = Convert.ToInt32(pixels); // set it. Done. private float GetDpiX() { floar returnValue; Graphics graphics = CreateGraphics(); returnValue = graphics.DpiX; graphics.Dispose(); // don’t forget to release the unnecessary resources return returnValue; } But this gives me different sizes with different resolutions. It gives me 13 cm with 1680 x 1050 and 19,5 cm with 1024 x 768. What am I doing wrong?

    Read the article

  • Formula for producing a CGRect for a UIScrollView, that displays a UIImage in scaled to fit way

    - by RickiG
    Hi I am loading in images with varying sizes and putting them in UIScrollViews, all the images are larger than the UIScrollView. The user can scroll and zoom as they please, but initially I would like for the image to be centered and scaled so the largest side of the image aligns with the edge of the scrollView, i.e. if the picture is in landscape I would like to size and scale it so that the left and right side goes all the way to the edge of the UIScrollVIew and vice versa I found a formula in a utility function in the Programming guide but it does not quite fit my needs. My approach is to use: CGrect initialPos = ? [self.scrollView zoomToRect:initialPos animated:YES]; I know the size of my scrollView and the size of my image, what I need to figure out is the scale and CGRect to apply to the scrollView to center and size my image. Hope someone can help out:) Thanks

    Read the article

  • How to find control points for a BezierSegment given Start, End, and 2 Intersection Pts in C# - AKA

    - by softwarequestioneer
    Hi, I've been struggling looking for an understandable way to do this. I have four points, a StartPt, EndPoint, and Intersection points to represent the peak and valley in the bezier. The BezierSegment in C# requires start, controlPoint 1, controlPoint 2, endpoint - however I don't have any control points I only have these two points that lie along the bezier curves (i'm calling them intersection points above)... how can I calculate the two control points? Thanks in advance, this has been driving me crazy. There's some kind of explanation here: http://www.tinaja.com/glib/nubz4pts1.pdf but it's written in postscript and that language makes no sense to me at all - it's over my head.

    Read the article

  • Algorithm for calculating definite integrals with bounds at infinity

    - by mbac32768
    Suppose I have an integral that's bounded on one (or both) end by (-)infinity. AFAICT, I can't analytically solve this problem, it takes brute force (e.g. using a Left Riemann Sum). I'm having trouble generalizing the algorithm so that it sets the proper subdivisions; I'll either do far too much work to calculate something trivial, or not do nearly enough and have huge aliasing errors. Answering in any language is cool, but maybe someone with better google-fu can end this quickly. :) Is what I'm looking for as impossible as trying to measure the British coastline?

    Read the article

  • Calculating intraday candlesticks by time intervals

    - by Sam
    This maybe an over asked question, but my mind draws blank at this moment. I know what a candlestick chart is and how to draw it daily. But how to draw it intraday at asked time periods. I have this server, written in Java, that gives me trade depth (each trade done since the start of the day). Its just a stream of raw data: price, shares, timestamp. How does one go about calculating candlestick data from that? Lets say, they want to have 5 min candlestick or 1min candlestick. Or is there a library that will do that for me if I feed it data? Any help is appreciated!

    Read the article

  • MySQL - Calculating fields on the fly vs storing calculated data

    - by Christian Varga
    Hi Everyone, I apologise if this has been asked before, but I can't seem to find an answer to a question that I have about calculating on the fly vs storing fields in a database. I read a few articles that suggested it was preferable to calculate when you can, but I would just like to know if that still applies to the following 2 examples. Example 1. Say you are storing data relating to a car. You store the fuel tank size in litres, and how many litres it uses per 100km. You also want to know how many KMs it can travel, which can be calculated from the tank size and economy. I see 2 ways of doing this: When a car is added or updated, calculate the amount of KMs and store this as a static field in the database. Every time a car is accessed, calculate the amount of KMs on the fly. Because the cars economy/tank size doesn't change (although it could be edited), the KMs is a pretty static value. I don't see why we would calculate it every single time the car is accessed. Wouldn't this waste cpu time as opposed to simply storing it in a separate field in the database and calculating only when a car is added or updated? My next example, which is almost an entirely different question (but on the same topic), relates to counting children. Let's say we have a app which has categories and items. We have a view where we display all the categories, and a count of all the items inside each category. Again, I'm wondering what's better. To perform a MySQL query to count all the items in each category every single time the page is accessed? Or store the count in a field in the categories table and update when an item is added / deleted? I know it is redundant to store anything that can be calculated, but I worry that calculating fields or counting records might be slow as opposed to storing the data in a field. If it's not then please let me know, I just want to learn about when to use either method. On a small scale I guess it wouldn't matter either way, but apps like Facebook, would they really count the amount of friends you have every time someone views your profile or would they just store it as a field? I'd appreciate any responses to both of these scenarios, and any resource that might explain the benefits of calculating vs storing. Thanks in advance, Christian

    Read the article

  • Algorithm for calculating indefinite integrals

    - by mbac32768
    Suppose I have an integral that's bounded on one (or both) ends by (-)infinity. AFAICT, I can't analytically solve this problem, it takes brute force (e.g. using a Left Riemann Sum). I'm having trouble generalizing the algorithm so that it sets the proper subdivisions; I'll either do far too much work to calculate something trivial, or not do nearly enough and have huge aliasing errors. Answering in any language is cool, but maybe someone with better google-fu can end this quickly. :) Is what I'm looking for as impossible as trying to measure the British coastline?

    Read the article

  • Finding cities close to one another using longitude and latitude

    - by Jamie
    Each user in my db is associated to a city (with it's longitude and latitude) How would I go about finding out which cities are close to one another? i.e. in England, Cambridge is fairly close to London. So If I have a user who lives in Cambridge. Users close to them would be users living in close surrounding cities, such as London, Hertford etc. Any ideas how I could go about this? And also, how would I define what is close? i.e. in the UK close would be much closer than if it were in the US as the US is far more spread out. Ideas and suggestions. Also, do you know any services that provide this sort of functionality? Thanks

    Read the article

  • Java: Calculate distance between a large number of locations and performance

    - by Ally
    I'm creating an application that will tell a user how far away a large number of points are from their current position. Each point has a longitude and latitude. I've read over this article http://www.movable-type.co.uk/scripts/latlong.html and seen this post http://stackoverflow.com/questions/837872/calculate-distance-in-meters-when-you-know-longitude-and-latitude-in-java There are a number of calculations (50-200) that need carried about. If speed is more important than the accuracy of these calculations, which one is best?

    Read the article

  • How many posibilities on a binary ?

    - by Val
    in hexadecimal "10 10 10 10" system you have 0-255 posibilities right? in total 256 different posibilities as there are 8 1s and 0s. how many different posibilities would i get? if i had 10 digits. instead of 8? or how would i calculate that in php ?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >