Search Results

Search found 1803 results on 73 pages for 'pi calculation'.

Page 53/73 | < Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >

  • C# is there a problem with division?

    - by Tom
    This is a piece of my code, it is called every second, after about 10 seconds the values start to become weird (see below): double a; double b; for (int i = 0; i < currAC.Length; i++ ) { a = currAC[i]; b = aveACValues[i]; divisor = (a/b); Console.WriteLine("a = " + a.ToString("N2") + "\t" + "b = " + b.ToString("N2")); Console.WriteLine("divisor = " + divisor); Console.WriteLine("a+b = " + (a+b)); } and the output: a = -0.05 b = 0.00 divisor = 41 a+b = -0.0524010372273268 currAC and aveACValues are double[] what on earth is going on???? The addition result is correct every time, but the division value is wrong, yet it is reading a and b correctly?? EDIT: '41' is the value of the first calculation, ie when a = currAC[0], but this should not remain???

    Read the article

  • C++ Word-Number to int

    - by Andrew
    I'm developing a program that makes basic calculations using words instead of numbers. E.g. five + two would output seven. The program becomes more complex, taking input such as two_hundred_one + five_thousand_six (201 + 5006) Through operator overloading methods, I split each number and assign it to it's own array index. two would be [0], hundred is [1], and one is [2]. Then the array recycles for 5006. My problem is, to perform the actual calculation, I need to convert the words stored in the array to actual integers. I have const string arrays such as this as a library of the words: const string units[] = { "", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; const string teens[] = { "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" }; const string tens[] = { "", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" }; If my 'token' array has stored in it two hundred one in index 0, 1, and 2, I'm not sure what the best way to convert these to ints would involve.

    Read the article

  • Can I prevent a computed column from changing it's value if the formula changes?

    - by William Hurst
    I have a computed column in MS SQL 2005 that does some VAT calculations. The website uses invoices that can only be generated once and rely on the value in the computed column to work out the VAT. Unfortunately, a bug was found that means that the the VAT value calculated was off by a few cents. Not a huge problem but we can't change the values from all the previously computed values as these need to be honoured on the invoices. tldr; How do I change the calculation for a computed column without re-calculating the values that have already be calculated?

    Read the article

  • Determining where to animate the map given a list of GeoPoints

    - by Itsik
    My android application loads some markers on an overlay onto a MapView. The markers are placed based on a dynamic list of GeoPoints. I want to move the map center and zoom into the area with most items. Naively, I can calculate the superposition of all the points, but I would like to remove the points that are very far from the mass of points from the calculation. Is there a known way to calculate this ? (e.g. probability, statistics .. ?)

    Read the article

  • [MATH]Project an axis to a plane

    - by Robert
    how do i project the X axis to a plane if the plane is defined by three points? see pic here: http://129.25.16.135:2080/v6.5/books/usb/graphics/iconventions-local-surfaces.png The default local 1-direction is the projection of the global x-axis onto the surface. If the global x-axis is within 0.1° of being normal to the surface, the local 1-direction is the projection of the global z-axis onto the surface. let's suppose that these points are: t1 = [-0.362879991531372, 0.357021987438202, -0.373737007379532] t2 = [-0.383525013923645, 0.371621012687683, -0.383549988269806] t3 = [-0.383534014225006, 0.34629300236702, -0.38544899225235] is the vector [0.78280971952246, -0.0307519963686645, 0.411184845614438] correct answer in this case? i've calculated the angle between the surf and x (1,0,0) is ~28°. and can you give the entire procedure for the calculation, because i'm just puzzled.

    Read the article

  • Distinct select on Oracle

    - by funktku
    What i am trying to do is a simple recommender , must take the biggest weighted top 40 element's node2 element. Calculation for weight comes from (E.WEIGHT * K.GRADE). Now this code succesfully returns top 40 elements. However, i don't want E.NODE2 to return duplicates. POSTGRE SQL allowed me to do SELECT DISTINCT ON (NODE2) E.NODE2 , (E.WEIGHT * K.GRADE). How can i do the same in oracle? The complete sql query; SELECT * FROM (SELECT DISTINCT E.NODE2 , (E.WEIGHT * K.GRADE) FROM KUAISFAST K, EDGES E WHERE K.ID = 1 AND K.COURSE_ID = E.NODE1 AND E.NODE2 NOT IN( SELECT K2.COURSE_ID FROM KUAISFAST K2 WHERE K2.ID = 1 ) ORDER BY( E.WEIGHT * K.GRADE ) DESC) TEMP WHERE rownum <= 40

    Read the article

  • Where should the line between property and method be?

    - by Catskul
    For many situations it is obvious whether something should be a property or a method however there are items that might be considered ambiguous. Obvious Properties: "name" "length" Obvious Methods: "SendMessage" "Print" Ambiguous: "Valid" / "IsValid" / "Validate" "InBounds" / "IsInBounds" / "CheckBounds" "AverageChildValue" / "CalcAverageChildValue" "ColorSaturation" / "SetColorSaturation" I suppose I would lean towards methods for the ambiguous, but does anyone know of a rule or convention that helps decide this? E.g. should all properties be O(1)? Should a property not be able to change other data (ColorSaturation might change R,G,B values)? Should it not be a property if there is calculation or aggregation? Just from an academic perspective, (and not because I think it's a good idea) is there a reason not to go crazy with properties and just make everything that is an interrogation of the class without taking an argument, and everything that can be changed about the class with a single argument and cant fail, a property?

    Read the article

  • how to debug VC++ program, input file not open while debuging

    - by zeedotcom
    i am using Visual studio 8. i pass command line argument to my program when i execute the program using exe file it works fine but when i use to debugg. it is unable to open the input file which i have given it in the form of command line argument. although i have given the command line argument in the Project-properties-debug-command line arguments.... e.g "program.exe" input_file output_file input file contains data which i have to use in the calculation if i am unable to debug it. how can i remove the errors in my program reply me thanks

    Read the article

  • When can we mock an object and its methods?

    - by Shailendra
    I am novice to the Moq and unit testing. I have to write unit tests to a lot of classes which has the objects of other classes. can i mock the methods of the class objects. Here is the exact scenerio- I have a class two classes A and B and A has a private object of B and in a method of A i am internally calling the method of B and then doing some calculation and returning the result. Can i mock the method of B in this scenerio? Please try to give me full detail about the conditions where i can mock the methods and functions of the class. Thanx

    Read the article

  • NHibernate Queries with Values Produced by Business Logic

    - by Lewis
    I have an NH query which returns a Product with a BasePrice. Depending on various other factors, such as Manufacturer price markup, I use a PricingService on the C# side of things to produce a "final" price. The issue is that I now need to query against this final value - i.e., I need to run a query that selects Products within a particular "final" price range. I'm thinking that my approach to this is all wrong, but I really didn't want to put the logic of the final price calculation in a SQL function or something like that, so any suggestions would be appreciated.

    Read the article

  • converting tag number to int

    - by Ehtesham Sajed
    i m using Visual C++2008. i've assigned tag value=2 of all buttons from button property(using drag n drop). now i want to make some math calculation with tag value. need to change it in int. what is the default data type tag? i used this code, //code sample if(((int)this-button1-Tag)((int)this-button2-Tag)((int)this-button3-Tag)==50) { ........ //i.e, if tag value of button1*tag value of button2*tag value of button 3==50 then... ........ } generated following run time error on a messegebox An unhandled exception of type 'System.InvalidCastException' occurred in learncpp1.exe Additional information: Specified cast is not valid.

    Read the article

  • Centre of a circle that intersects two points

    - by Jason
    Given two points in a 2D plane, and a circle of radius r that intersects both of those points, what would be the formula to calculate the centre of that circle? I realise there would two places the circle can be positioned. I would want the circle whose centre is encountered first in a clockwise direction when sweeping the line that joins the two points around one of those points, starting from an arbitrary angle. I guess that is the next stage in my problem, after I find an answer for the first part. I'm hoping the whole calculation can be done without trigonometry for speed. I'm starting with integer coordinates and will end with integer coordinates, if that helps.

    Read the article

  • Encrypt/ Decrypt text file in Delphi?

    - by Hemant Kothiyal
    Hi i would like to know best encryption technique for text file encryption and ecryption. My Scenario: I have software having two type of users Administartor and Operators. Our requirement is to encrypt text file when Administrator enter data using GUI and save it. That encrypted file would be input for Operator and they just need to select it and use that file. Here file should be automatically decrypt data for further calculation when Operator select those files. Please help me which encryption/ decryption technique should i use?

    Read the article

  • Iterating over a database column in Django

    - by curious
    I would like to iterate a calculation over a column of values in a MySQL database. I wondered if Django had any built-in functionality for doing this. Previously, I have just used the following to store each column as a list of tuples with the name table_column: import MySQLdb import sys try: conn = MySQLdb.connect (host = "localhost", user = "user", passwd="passwd", db="db") except MySQLdb.Error, e: print "Error %d: %s" % (e.args[0], e.args[1]) sys.exit (1) cursor = conn.cursor() for table in ['foo', 'bar']: for column in ['foobar1', 'foobar2']: cursor.execute('select %s from %s' % (column, table)) exec "%s_%s = cursor.fetchall()" % (table, column) cursor.close() conn.commit() conn.close() Is there any functionality built into Django to more conveniently iterate through the values of a column in a database table? I'm dealing with millions of rows so speed of execution is important.

    Read the article

  • Why is numpy c extension slow?

    - by Bitwise
    I am working on large numpy arrays, and some native numpy operations are too slow for my needs (for example simple operations such as "bitwise" A&B). I started looking into writing C extensions to try and improve performance. As a test case, I tried the example given here, implementing a simple trace calculation. I was able to get it to work, but was surprised by the performance: for a (1000,1000) numpy array, numpy.trace() was about 1000 times faster than the C extension! This happens whether I run it once or many times. Is this expected? Is the C extension overhead that bad? Any ideas how to speed things up?

    Read the article

  • Highest value datatype can store in c#

    - by user472832
    I am writing a small program for my assignment to find the primitive roots of a prime number. So far, the program works for smaller prime numbers till 13 and gives correct number of roots. But for higher primes numbers, it is showing only fewer primitive roots. And now i got stuck for the prime number 41, shows no primitive roots for it. I used DOUBLE datatype for the calculation, and again tried with the datatype DECIMAL, but no luck. Does anyone know about this kind of problem??? Thank you.

    Read the article

  • How to write a CASE WHEN statement with multiple DATEDIFF variables

    - by Anne C
    I need to calculate the difference between two dates (facility_start_date, facility_end_date) for a report in Reporting Services in SQL 2005. If the facility_end_date is null then it needs to use the report parameter @EndDate in the calculation. However if the facility_end_date is greater than the parameter @EndDate, then it also needs to use the paramenter @EndDate. The code below works fine except that if the facility_end_date is greater than the parameter @EndDate it is still calculating between the facility_start_date and facility_end_date, rather than between the facility_start_date and @EndDate. Any help would be appreciated. CASE WHEN facility_start_date > facility_end_date THEN NULL WHEN DATEPART(day , facility_start_date) > DATEPART(day , facility_end_date) THEN DATEDIFF(d , facility_start_date , ISNULL(facility_end_date , @EndDate)) - 1 WHEN DATEPART(day , .facility_end_date) > DATEPART(day , @EndDate) THEN DATEDIFF(d , facility_start_date , @EndDate) - 1 ELSE DATEDIFF(d , facility_start_date , ISNULL facility_end_date , @EndDate)) END

    Read the article

  • How to calculate the state of a graph?

    - by zcb
    Given a graph G=(V,E), each node i is associated with 'Ci' number of objects. At each step, for every node i, the Ci objects will be taken away by the neighbors of i equally. After K steps, output the number of objects of the top five nodes which has the most objects. Some Constrains: |V|<10^5, |E|<2*10^5, K<10^7, Ci<1000 My current idea is: represent the transformation in each step with a matrix. This problem is converted to the calculation of the power of matrix. But this solution is much too slow considering |V| can be 10^5. Is there any faster way to do it?

    Read the article

  • Recursively determine average value

    - by theva
    I have to calculate an average value of my simulation. The simulation is ongoing and I want (for each iteration) to print the current average value. How do I do that? I tried the code below (in the loop), but I do not think that the right value is calculated... int average = 0; int newValue; // Continuously updated value. if(average == 0) { average = newValue; } average = (average + newValue)/2; I also taught about store each newValue in an array and for each iteration summarize the whole array and do the calculation. However, I don't think that's a good solution, because the loop is an infinity loop so I can't really determine the size of the array. There is also a possibility that I am thinking too much and that the code above is actually correct, but I don't think so...

    Read the article

  • Index out of range exception when using this query from C#

    - by jenifa
    I am using a calculation in my SQL query. How can I use that calculated field in C#? When I try, I get an index out of range exception. My query is: Select OwnerCompanyLog.olog_name,inlt_companyid,inlt_childcompid,inlt_effectinterest,inlt_percent,inlt_sharetype,inlt_shares,inlt_childbase,inlt_effdate, (inlt_percent * inlt_effectinterest)/100)eff from InterestLogTable INNER JOIN OwnerCompanyLog ON InterestLogTable.inlt_childcompid = OwnerCompanyLog.olog_companyid where inlt_companyid=5 Order By inlt_childcompid I want to use inlt_percent * inlt_effectinterest)/100 in my C# code: entity.ParentCompany = new List<Company>(); while (parentCompanyReader.Read()) { ParentCompany.Effect = parentCompanyReader["eff"].ToString(); entity.ParentCompany.Add(ParentCompany); } parentCompanyReader.Close(); But I got the error above.

    Read the article

  • Database that accesses a website.?

    - by Alec
    Hi Guys What application should I use that is able to automatically access a website to gather information? Basically I have a database that completes calculations for me; however I have to manually gather the parameters from a website and input these into my database. What I would like is have an application that will take my input say the name of a product, access the website, add this name into a search box on a website, complete the search and then extract the desired information from the web page returning the results to my application to complete the calculation thus presenting me with the result. This is a little out of my depth but I’m willing to learn no matter how complicated the software. Cheers for your help.

    Read the article

  • Problem removing a dynamic form field in jquery

    - by rshivers
    I'm trying to remove a dynamic form field by click a button. It will also subtract whatever values it had from the total amount from my calculation. This is the code: function removeFormField(id) { var id = $(id).attr("name"); $('#target1').text($("#total" + id).map(function() { var currentValue = parseFloat(document.getElementById("currentTotal").value); var newValue = parseFloat($("#total" + id).text()); var newTotal = currentValue - newValue; document.getElementById("currentTotal").value = newTotal; return newTotal; }).get().join()); $(id).remove(); } Okay, it will do the subtraction portion of the code with no problem, this issue is with the last line to remove the field. If I comment out the rest of the code it will work, but not with the rest of the code. I know this is something simple, yet I can't seem to wrap my mind around it. Can someone please help?

    Read the article

  • Convert "minutes since midnight" to time (convert to NSDate?)

    - by Canada Dev
    I am getting some open/closed times as integers since midnight. For example: "1140" = 19:00 (or 7 pm if you will) or; "570" = 9:30 (or 9.30 am) I can easily get the time in European format, just by doing doing a simple calculation and formatting: [NSString stringWithFormat:@"%d:00", (T / 60)] However, this doesn't work for half hours, such as "570 minutes since midnight". Also, I run into problems if I want to include a bit of localization, because some people may prefer AM/PM times. Does NSDate include a method for easily implementing times using the above? Or can anyone tell me how I would at least convert a time like "570 minutes since midnight" to 9:30 properly. Right now it obviously won't write the :30 part. Thank you

    Read the article

  • Parallel.For(): Update variable outside of loop

    - by TSS
    I'm just looking in to the new .NET 4.0 features. With that, I'm attempting a simple calculation using Parallel.For and a normal for(x;x;x) loop. However, I'm getting different results about 50% of the time. long sum = 0; Parallel.For(1, 10000, y => { sum += y; } ); Console.WriteLine(sum.ToString()); sum = 0; for (int y = 1; y < 10000; y++) { sum += y; } Console.WriteLine(sum.ToString()); My guess is that the threads are trying to update "sum" at the same time. Is there an obvious way around it?

    Read the article

  • How do I find the viewable area of a WPF RichTextBox?

    - by shoe
    I'm working on an app where I have a bunch of text in a RichTextBox. I'm jumping to various positions within the text, (hopping to an arbitrary paragraph for example) which seems to work by send the caret to that position but I can't seem to control where in the viewable area the caret ends up. Sometimes the caret ends up at the top of the RichTextBox and sometimes at the bottom. This would be fine if I was only interested in the line that the caret is on but I'm interested in the entire paragraph.Ideally I'd like to get the caret in the middle of the RichTextBox everytime. Unless the Paragraph is longer than the viewable area. My question. Is there a way to determine the viewable area of a RichTextBox and so do a calculation on how to position the caret properly? If I had that value I can then decided whether to put the caret in the middle (and know where the middle is) or at the top. Thanks for you help.

    Read the article

< Previous Page | 49 50 51 52 53 54 55 56 57 58 59 60  | Next Page >