Search Results

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

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

  • Java days of week calculation

    - by Shahid
    I have an Enum for Days of week (with Everyday, weekend and weekdays) as follows where each entry has an int value. public enum DaysOfWeek { Everyday(127), Weekend(65), Weekdays(62), Monday(2), Tuesday(4), Wednesday(8), Thursday(16), Friday(32), Saturday(64), Sunday(1); private int bitValue; private DaysOfWeek(int n){ this.bitValue = n; } public int getBitValue(){ return this.bitValue; } } Given a TOTAL of any combination of the entries, what would be the simplest way to calculate all individual values and make an arraylist from it. For example given the number 56 (i.e. Wed+Thur+Fri), how to calculate the list of individual values.

    Read the article

  • drawing circle without floating point calculation

    - by zaharpopov
    This is common interview question (according to some interview sites) but I can find no normal answers in Internet - some are wrong and some point to complex theory I expect not looked for in interview (like Bressenham algorithm). The question is simple: The circle equation is: x^2 + y^2 = R^2. Given R, draw 0,0-centered circle as best as possible without using any floating point (no trigo, square roots, and so on, only integers)

    Read the article

  • time calculation with awk

    - by vbd
    I've got a file, which looks like: Coding |2010-04-20 12:52|2010-04-20 14:11 Documentation|2010-04-20 22:56|2010-04-21 01:13 Coding |2010-04-21 09:51|2010-04-21 10:58 Coding |2010-04-21 13:11|2010-04-21 14:21 What's the best way - I'm thinking of awk - to do time calculations. As result I expect: 2010-04-20 Coding 69 2010-04-21 Documentation 137 2010-04-21 Coding 137 Can this be done with awk?

    Read the article

  • Calculation of average and Timestamping

    - by user554230
    pls do sumone help me to solve this for me and the number should be variable and not constant. the output should be: Timestamping In 6 Digit 8 5 6 3 0 1 Average In 6 Digit 9 8 7 6 5 2 class Timestamp1 extends Average1 { public static void main (String args[]) { int i = 103658; int j = 10; int k = i % j; System.out.println(" Timestamping In 6 Digit " ); System.out.println(" " + k); int o = 10365; int p = 10; int q = o % p; System.out.println(" " + q); int l = 1036; int m = 10; int n = l % m; System.out.println(" " + n); int r = 103; int s = 10; int t = r % s; System.out.println(" " + t); int u = 10; int v = 10; int w = u % v; System.out.println(" " + w); int x = 1; int y = 10; int z = x % y; System.out.println(" " + z); class Average1 extends Timestamp1 { public void main() { int i = 256789; int j = 10; int k = i % j; System.out.println(" Average In 6 Digit "); System.out.println(" " + k); int o = 25678; int p = 10; int q = o % p; System.out.println(" " + q); int l = 2567; int m = 10; int n = l % m; System.out.println(" " + n); int r = 256; int s = 10; int t = r % s; System.out.println(" " + t); int u = 25; int v = 10; int w = u % v; System.out.println(" " + w); int x = 2; int y = 10; int z = x % y; System.out.println(" " + z); } } } }

    Read the article

  • time calculation within LINQ

    - by d daly
    Hi I want a linq query to return a calculated timespan, i have used the timespan function before, but im not sure how to incorporate it into linq. Basically the linq is returning a datetime field which i want to subtract from the current datetime to get days and hours. Any help appreciated! Thanks

    Read the article

  • Simple average calculation

    - by sasquatch90
    I'm trying to write program calculating average of given numbers stored in an array. Amount of numbers should be not more than 100, and user should input them until a !int variable is given : #include <iostream> #include <conio.h> using namespace std; double average(int tab[], int i){ int sum=0; for(int j=0; j<i; ++j){ sum+=tab[j]; } return (double)sum/i; } int main() { int tab[100]; int n=0; int number=0; do { if(n < 100){ cout << "Give " << n+1 << " number : "; cin >> number; tab[n]=number; number=0; ++n; } else{ break; } } while( !isdigit(number) ); cout << average(tab, n) << endl; getch(); return 0; } Why after giving char, it prints me 'Give n number:' for all empty cells of my array ? It should end and use only given numbers.

    Read the article

  • Simple calculation in SQL Server

    - by meep
    I got a distance field in my database that stores the distance traveled on a specific route. I need to select all the distance fields and plus them together, then returning the result from my stored procedure. How can this be done?

    Read the article

  • Time Calculation in Python

    - by user343934
    Hi everyone, I have two python cgi pages (index, display), what i need to do is calculate time frame between the execution. Work flow: Index.py (submit) After submit it redirect to display.py page display.py page has got class with execute(),display() &init_main() functions In init_main() i have created class object which access to above functions I need to calculate time interval between the submit (index.py) to execute() end, so i can show user how much time does different weighted file takes on real time. Hoping to see your suggestions Thanks

    Read the article

  • python len calculation

    - by n00bz0r
    I'm currently trying to build a RDP client in python and I came across the following issue with a len check; From: http://msdn.microsoft.com/en-us/library/cc240836%28v=prot.10%29.aspx "81 2a - ConnectData::connectPDU length = 298 bytes Since the most significant bit of the first byte (0x81) is set to 1 and the following bit is set to 0, the length is given by the low six bits of the first byte and the second byte. Hence, the value is 0x12a, which is 298 bytes." This sounds weird. For normal len checks, I'm simply using : struct.pack("h",len(str(PacketLen))) but in this case, I really don't see how I can calculate the len as described above. Any help on this would be greatly appreciated !

    Read the article

  • biginteger calculation problem

    - by murali
    I am using the following code but the parameters are not passed to the methods. BigInteger p = BigInteger.valueOf(0); BigInteger u1 = obj.bigi_calc(g1, l); In this g1,l are long values. The method is private BigInteger bigi_calc(long g1, long l){ BigInteger cal = BigInteger.valueOf(g1); BigInteger cal1= BigInteger.valueOf(l); for(BigInteger f = BigInteger.ONE;f.compareTo(cal1)>0;f=f.add(BigInteger.ONE)){ //BigInteger p= BigInteger.valueOf(0); p = cal.multiply(cal1); System.out.println("check p"+p); } // System.out.println("check p"+p); return p; } The elipse shows that it may be out of sync, but the parameters are not passed to the functions. Can you please help me to solve this problem?

    Read the article

  • bitfield mask calculation macro

    - by Aidan Cully
    We have a set of C macros, here, for using the preprocessor to do bitfield operations, and we run into warnings when attempting to use these macros in visual studio. The problem can be demonstrated very easily: #define BITFIELD_WIDTHMASK(Width) \ ((Width) >= 32 ? ~0x0ul : (1ul << (Width)) - 1) unsigned long foo(void) { return BITFIELD_WIDTHMASK(32); } Compiling this with MSVC yields the warning: test.c(12) : warning C4293: '<<' : shift count negative or too big, undefined behavior This isn't a behavior problem - the << operator won't be used in this case, and that should be detected at compile time. But does anyone have any suggestions about how to rewrite the macro to avoid the warning? Or, failing that, how to redesign the macro interface for this? Thanks in advance

    Read the article

  • views count calculation

    - by Alexey Poimtsev
    Hi, could you give me idea how to calculate unique views of page? If i will increase counter on each page load it will be no good, otherside storing information of viewed pages in session looks like not ideal solution.

    Read the article

  • Strange calculation problem in C multiply by 1.2 fails

    - by DoomStone
    I have this c code, where i need to calculate a dobule from a long. double result; long t2_value; t2_value = 72; result = t2_value * 1.2; Now this code crashes at "result = t2_value * 1.2;" only with the error "Vector 0000000006". Here is the strange thing, if i replace result = t2_value * 1.2; with result = 72 * 1.2; evything works just as it should, i have tryed type casting t2_value as an double result = ((double)t2_value * 1.2); or making it an int istead of a long, but nothing helps.

    Read the article

  • Efficient way to store a graph for calculation in Hadoop

    - by user337499
    I am currently trying to perform calculations like clustering coefficient on huge graphs with the help of Hadoop. Therefore I need an efficient way to store the graph in a way that I can easily access nodes, their neighbors and the neighbors' neighbors. The graph is quite sparse and stored in a huge tab separated file where the first field is the node from which an edge goes to the second node in field two. Thanks in advance!

    Read the article

  • Java redirected system output to jtext area, doesnt update until calculation is finished

    - by user1806716
    I have code that redirects system output to a jtext area, but that jtextarea doesnt update until the code is finished running. How do I modify the code to make the jtextarea update in real time during runtime? private void updateTextArea(final String text) { SwingUtilities.invokeLater(new Runnable() { public void run() { consoleTextAreaInner.append(text); } }); } private void redirectSystemStreams() { OutputStream out = new OutputStream() { @Override public void write(int b) throws IOException { updateTextArea(String.valueOf((char) b)); } @Override public void write(byte[] b, int off, int len) throws IOException { updateTextArea(new String(b, off, len)); } @Override public void write(byte[] b) throws IOException { write(b, 0, b.length); } }; System.setOut(new PrintStream(out, true)); System.setErr(new PrintStream(out, true)); } The rest of the code is mainly just an actionlistener for a button: private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: String shopRoot = this.shopRootDirTxtField.getText(); String updZipPath = this.updateZipTextField.getText(); this.mainUpdater = new ShopUpdater(new File(shopRoot), updZipPath); this.mainUpdater.update(); } That update() method begins the process of copying+pasting files on the file system and during that process uses system.out.println to provide an up-to-date status on where the program is currently at in reference to how many more files it has to copy.

    Read the article

  • Date range advanced count calculation in TSQL

    - by cihata87
    I am working on call center project and I have to calculate the call arrivals at the same time between specific time ranges. I have to write a procedure which has parameters StartTime, EndTime and Interval For Example: Start Time: 11:00 End Time: 12:00 Interval: 20 minutes so program should divide the 1-hour time range into 3 parts and each part should count the arrivals which started and finished in this range OR arrivals which started and haven't finished yet Should be like this: 11:00 - 11:20 15 calls at the same time(TimePeaks) 11:20 - 11:40 21 calls ... 11:40 - 12:00 8 calls ... Any suggestions how to calculate them?

    Read the article

  • Order a foreach, by the value of a calculation of values in the array

    - by Mark
    I have an array as follows: $players = array( $player = array( 'name' => 'playername', 'speed' => '10', 'agility' => '10', 'influence' => '10' ) etc Then I calculate a $score, based on the sum of speed, agility and influence. $score = $p['speed'] + $p['agility'] + $p['influence']; How can I loop through my array, but order the results from highest to lowest $score? PS- http://pastebin.com/eUEQ5y4u

    Read the article

  • % operator for time calculation

    - by Chris
    I am trying to display minutes and seconds based on a number of seconds. I have: float seconds = 200; float mins = seconds / 60.0; float sec = mins % 60.0; [timeIndexLabel setText:[NSString stringWithFormat:@"%.2f , %.2f", mins,seconds]]; But I get an error: invalid operands of types 'float' and 'double' to binary 'operator%' And I don't understand why... Can someone throw me a bone!?

    Read the article

  • DataGrid calculate difference between values in two databound cells

    - by justMe
    Hello! In my small application I have a DataGrid (see screenshot) that's bound to a list of Measurement objects. A Measurement is just a data container with two properties: Date and CounterGas (float). Each Measurement object represents my gas consumption at a specific date. The list of measurements is bound to the DataGrid as follows: <DataGrid ItemsSource="{Binding Path=Measurements}" AutoGenerateColumns="False"> <DataGrid.Columns> <DataGridTextColumn Header="Date" Binding="{Binding Path=Date, StringFormat={}{0:dd.MM.yyyy}}" /> <DataGridTextColumn Header="Counter Gas" Binding="{Binding Path=ValueGas, StringFormat={}{0:F3}}" /> </DataGrid.Columns> </DataGrid> Well, and now my question :) I'd like to have another column right next to the column "Counter Gas" which shows the difference between the actual counter value and the last counter value. E.g. this additional column should calculate the difference between the value of of Feb. 13th and Feb. 6th = 199.789 - 187.115 = 15.674 What is the best way to achieve this? I'd like to avoid any calculation in the Measurement class which should just hold the data. I'd rather more like the DataGrid to handle the calculation. So is there a way to add another column that just calculates the difference between to values? Maybe using some kind of converter and extreme binding? ;D P.S.: Maybe someone with a better reputation could embed the screenshot. Thanks :)

    Read the article

  • jQuery changing fields to substring of related field

    - by Katherine
    Another jquery calculation question. I've this, which is sample code from the plugin site that I am playing with to get this working: function recalc(){ $("[id^=total_item]").calc( "qty * price", { qty: $("input[name^=qty_item_]"), price: $("input[name^=price_item_]"), }, function (s){ return s.toFixed(2);}, function ($this){ var sum = $this.sum(); $("#grandTotal").val( // round the results to 2 digits sum.toFixed(2) ); } ); } Changes in the price fields cause the totals to update: $("input[name^=price_item_]").bind("keyup", recalc); recalc(); Problem is I won't know the value of the price fields, they will be available to me only as a substring of values entered by the user, call it 'itemcode'. There will be a variable number of items, based on a php query. I've come up with this to change the price based on the itemcode: $("input[name^='itemcode_item_1']").keyup(function () { var codeprice = this.value.substring(2,6); $("input[name^='price_item_1']").val(codeprice); }); $("input[name^='itemcode_item_2']").keyup(function () { var codeprice = this.value.substring(2,6); $("input[name^='price_item_2']").val(codeprice); }); However while it does that, it also stops the item_total from updating. Also, I feel there must be a way to not need to write a numbered function for each item on the list. However when I just use $("input[name^='itemcode_item_']") updating any itemcode field updates all price fields, which is not good. Can anyone point me in the right direction? I know I am a bit clueless here, but javascript of any kind is not my thing.

    Read the article

  • Getting TexBox's ID's .... to Calculate

    - by jjj
    i have : vb code: Private Sub Calculation() Dim txt1 As Decimal txt1 = (CS_Incoms_done.Text / CS_Incoms_target.Text) * 100 CS_Incom_Result.Text = "%" + FormatNumber(txt, 2, TriState.False) Dim txt2 As Decimal txt2 = (CS_GovernmentService_done.Text / CS_GovernmentService_target.Text) * 100 CS_GovernmentService_Result.Text = "%" + FormatNumber(txt2, 2, TriState.False) Dim txt3 As Decimal txt3 = (CS_RentBox_done.Text / CS_RentBox_target.Text) * 100 CS_RentBox_Result.Text = "%" + FormatNumber(txt3, 2, TriState.False) Dim txt4 As Decimal txt4 = (CS_ServiceAdvertising_done.Text / CS_ServiceAdvertising_target.Text) * 100 CS_ServiceAdvertising_Result.Text = "%" + FormatNumber(txt4, 2, TriState.False) Dim txt5 As Decimal txt5 = (CS_ServiceCatogray_done.Text / CS_ServiceCatogray_target.Text) * 100 CS_ServiceCatogray_Result.Text = "%" + FormatNumber(txt5, 2, TriState.False) End Sub i just show you 5 textbox's of 100 textbox's .... and don't want to complete all the textbox's like this ... i want a simple code to do it.. ... as you notice , every three textbox's are look a like on the first two parts of their id's..~ for example -- CS_ServiceCatogray _Result.Text, CS_ServiceCatogray _done.Text and CS_ServiceCatogray _target.Text... ~..and the last part is the same in all textbox's for geving the Result .. _Result.Text , _done.Text and _target.Text So... i had an idea to take the id and put the Similar two parts in an array... and use For Each something like: Dim allItems As Array For Each item As Control In panel4.Controls Select Case item.[GetType]().Name Case "TextBox" 'here just be sure that this item is not saved in the allItems array ,if it is not do >>' allItems[Last_Item_Saved_Index+1] = DirectCast(item, TextBox).ID ', but i want to save just the two Similar parts of the textboxs ids' 'i am not sure if this completely correct, but i wanted to do something like it[' Dim partOFtxt As String = allItems[Last_Item_Saved_Index] Dim txt As Decimal = (partOFtxt + "_done.Text") / (partOFtxt + "_target.Text") (partOFtxt + "_Result.Text") = "%" + FormatNumber(txt, 2, TriState.False) ']' 'end condition' Exit Select Case Else Exit Select End Select Next i hope that you get the idea.. if you have a better idea ... it would be nice.. Thanks in advance..

    Read the article

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