Search Results

Search found 6587 results on 264 pages for 'double dispatch'.

Page 11/264 | < Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >

  • Hibernate: Found: float, expected: double precision

    - by Frederic Morin
    I have a problem with the mapping of Oracle Float double precision datatype to Java Double datatype. The hibernate schema validator seems to fail when the Java Double datatype is used. org.hibernate.HibernateException: Wrong column type in DB.TABLE for column amount. Found: float, expected: double precision The only way to avoid this is to disable schema validation and hope the schema is in sync with the app about to run. I must fix this before it goes out to production. App's evironment: - Grails 1.2.1 - Hibernate-core 3.3.1.GA - Oracle 10g

    Read the article

  • How can one prevent double encoding of html entities when they are allowed in the input

    - by Bob
    How can I prevent double encoding of html entities, or fix them programmatically? I am using the encode() function from the HTML::Entities perl module to encode HTML entities in user input. The problem here is that we also allow users to input HTML entities directly and these entities end up being double encoded. For example, a user may enter: Stackoverflow & Perl = Awesome&hellip; This ends up being encoded to Stackoverflow &amp; Perl = Awesome&amp;hellip; This renders in the browser as Stackoverflow & Perl = Awesome&hellip; We want this to render as Stackoverflow & Perl = Awesome... Is there a way to prevent this double encoding? Or is there a module or snippet of code that can easily correct these double encoding issues? Any help is greatly appreciated!

    Read the article

  • Use of const double for intermediate results

    - by Arne
    Hi, I a writing a Simulation program and wondering if the use of const double is of any use when storing intermediate results. Consider this snippet: double DoSomeCalculation(const AcModel &model) { (...) const double V = model.GetVelocity(); const double m = model.GetMass(); const double cos_gamma = cos(model.GetFlightPathAngleRad()); (...) return m*V*cos_gamma*Chi_dot; } Note that the sample is there only to illustrate -- it might not make to much sense from the engineering side of things. The motivation of storing for example cos_gamma in a variable is that this cosine is used many time in other expressions covered by (...) and I feel that the code gets more readable when using cos_gamma rather than cos(model.GetFlightPathAngleRad()) in various expressions. Now the actual is question is this: since I expect the cosine to be the same througout the code section and I actually created the thing only as a placeholder and for convenience I tend to declare it const. Is there a etablished opinion on wether this is good or bad practive or whether it might bite me in the end? Does a compiler make any use of this additional information or am I actually hindering the compiler from performing useful optimizations? Arne

    Read the article

  • Convert any currency string to double

    - by James
    I need to store multiple currencies in SQL server. I understand that SQL won't support all different types of currencies (unless I store it as a string, but I don't want to do that). My idea was to convert all the values from their currency format to a standard double and store that instead. Then just re-format based on the culture info when displaying. However, I have tried doing something like e.g. var cultureInfo = new System.Globalization.CultureInfo("en-US"); double plain = return Double.Parse("$20,000.00", cultureInfo); This doesn't ever seem to work it always throws a FormatException. Even removing the currency symbol and just trying to do this based on the number alone does the same thing. This is just an example I want to support pretty much any type of currency. Is there a standard way of stripping out currency and getting the value as a double?

    Read the article

  • floor of double(time_t)

    - by plok
    I cannot understand why this throws undefined reference to `floor'": double curr_time = (double)time(NULL); return floor(curr_time); Hasn't it been casted to double, which is what floor receives?

    Read the article

  • Float addition promoted to double?

    - by Andreas Brinck
    I had a small WTF moment this morning. Ths WTF can be summarized with this: float x = 0.2f; float y = 0.1f; float z = x + y; assert(z == x + y); //This assert is triggered! (Atleast with visual studio 2008) The reason seems to be that the expression x + y is promoted to double and compared with the truncated version in z. (If i change z to double the assert isn't triggered). I can see that for precision reasons it would make sense to perform all floating point arithmetics in double precision before converting the result to single precision. I found the following paragraph in the standard (which I guess I sort of already knew, but not in this context): 4.6.1. "An rvalue of type float can be converted to an rvalue of type double. The value is unchanged" My question is, is x + y guaranteed to be promoted to double or is at the compiler's discretion? UPDATE: Since many people has claimed that one shouldn't use == for floating point, I just wanted to state that in the specific case I'm working with, an exact comparison is justified. Floating point comparision is tricky, here's an interesting link on the subject which I think hasn't been mentioned.

    Read the article

  • Double paging definition

    - by Albinoswordfish
    This is not a programming question but more of an operating system question Right now I'm trying to learn what exactly Double paging means. I see two different terms, double paging on disk and double paging in memory. Apparently this problem arises when we introduce a buffer cache to store disk blocks when doing File I/O But I'm not really sure what exactly this term means. If anybody could specify it would be very helpful.

    Read the article

  • What does it mean to double license?

    - by Adrian Panasiuk
    What does it mean to double license code? I can't just put both licenses in the source files. That would mean that I mandate users to follow the rules of both of them, but the licenses will probably be contradictory (otherwise there'd be no reason to double license). I guess this is something like in cryptographic chaining, cipher = crypt_2(crypt_1(clear)) (generally) means, that cipher is neither the output of crypt_2 on clear nor the output of crypt_1 on clear. It's the output of the composition. Likewise, in double-licensing, in reality my code has one license, it's just that this new license says please follow all of the rules of license1, or all of the rules of license2, and you are hereby granted the right to redistribute this application under this "double" license, license1 or license2, or any license under which license1 or license2 allow you to redistribute this software, in which case you shall replace the relevant licensing information in this application with that of the new license. (Does this mean that before someone may use the app under license1, he has to perform the operation of redistributing to self? How would he document the fact that he did that operation?) Am I correct. What LICENSE file and what text to put in the source files would I need if I wanted to double license on, for the sake of example, Apachev2 and GPLv3 ?

    Read the article

  • system out output for double numbers in a java program

    - by Nikunj Chauhan
    I have a program where I am generating two double numbers by adding several input prices from a file based on a condition. String str; double one = 0.00; double two = 0.00; BufferedReader in = new BufferedReader(new FileReader(myFile)); while((str = in.readLine()) != null){ if(str.charAt(21) == '1'){ one += Double.parseDouble(str.substring(38, 49) + "." + str.substring(49, 51)); } else{ two += Double.parseDouble(str.substring(38, 49) + "." + str.substring(49, 51)); } } in.close(); System.out.println("One: " + one); System.out.println("Two: " + two); The output is like: One: 2773554.02 Two: 6.302505836000001E7 Question: None of the input have more then two decimals in them. The way one and two are getting calculated exactly same. Then why the output format is like this. What I am expecting is: One: 2773554.02 Two: 63025058.36 Why the printing is in two different formats ? I want to write the outputs again to a file and thus there must be only two digits after decimal.

    Read the article

  • Memory leaks while using array of double

    - by Gacek
    I have a part of code that operates on large arrays of double (containing about 6000 elements at least) and executes several hundred times (usually 800) . When I use standard loop, like that: double[] singleRow = new double[6000]; int maxI = 800; for(int i=0; i<maxI; i++) { singleRow = someObject.producesOutput(); //... // do something with singleRow // ... } The memory usage rises for about 40MB (from 40MB at the beggining of the loop, to the 80MB at the end). When I force to use the garbage collector to execute at every iteration, the memory usage stays at the level of 40MB (the rise is unsignificant). double[] singleRow = new double[6000]; int maxI = 800; for(int i=0; i<maxI; i++) { singleRow = someObject.producesOutput(); //... // do something with singleRow // ... GC.Collect() } But the execution time is 3 times longer! (it is crucial) How can I force the C# to use the same area of memory instead of allocating new ones? Note: I have the access to the code of someObject class, so if it would be needed, I can change it.

    Read the article

  • Java code optimization leads to numerical inaccuracies and errors

    - by rano
    I'm trying to implement a version of the Fuzzy C-Means algorithm in Java and I'm trying to do some optimization by computing just once everything that can be computed just once. This is an iterative algorithm and regarding the updating of a matrix, the clusters x pixels membership matrix U, this is the update rule I want to optimize: where the x are the element of a matrix X (pixels x features) and v belongs to the matrix V (clusters x features). And m is a parameter that ranges from 1.1 to infinity. The distance used is the euclidean norm. If I had to implement this formula in a banal way I'd do: for(int i = 0; i < X.length; i++) { int count = 0; for(int j = 0; j < V.length; j++) { double num = D[i][j]; double sumTerms = 0; for(int k = 0; k < V.length; k++) { double thisDistance = D[i][k]; sumTerms += Math.pow(num / thisDistance, (1.0 / (m - 1.0))); } U[i][j] = (float) (1f / sumTerms); } } In this way some optimization is already done, I precomputed all the possible squared distances between X and V and stored them in a matrix D but that is not enough, since I'm cycling througn the elements of V two times resulting in two nested loops. Looking at the formula the numerator of the fraction is independent of the sum so I can compute numerator and denominator independently and the denominator can be computed just once for each pixel. So I came to a solution like this: int nClusters = V.length; double exp = (1.0 / (m - 1.0)); for(int i = 0; i < X.length; i++) { int count = 0; for(int j = 0; j < nClusters; j++) { double distance = D[i][j]; double denominator = D[i][nClusters]; double numerator = Math.pow(distance, exp); U[i][j] = (float) (1f / (numerator * denominator)); } } Where I precomputed the denominator into an additional column of the matrix D while I was computing the distances: for (int i = 0; i < X.length; i++) { for (int j = 0; j < V.length; j++) { double sum = 0; for (int k = 0; k < nDims; k++) { final double d = X[i][k] - V[j][k]; sum += d * d; } D[i][j] = sum; D[i][B.length] += Math.pow(1 / D[i][j], exp); } } By doing so I encounter numerical differences between the 'banal' computation and the second one that leads to different numerical value in U (not in the first iterates but soon enough). I guess that the problem is that exponentiate very small numbers to high values (the elements of U can range from 0.0 to 1.0 and exp , for m = 1.1, is 10) leads to ver y small values, whereas by dividing the numerator and the denominator and THEN exponentiating the result seems to be better numerically. The problem is it involves much more operations. Am I doing something wrong? Is there a possible solution to get both the code optimized and numerically stable? Any suggestion or criticism will be appreciated.

    Read the article

  • Double multiplied by 100 and then cast to long is giving wrong value

    - by xyz
    I have the following code: Double i=17.31; long j=(long) (i*100); System.out.println(j); O/P : 1730 //Expected:1731 Double i=17.33; long j=(long) (i*100); System.out.println(j); O/P : 1732 //Expected:1733 Double i=17.32; long j=(long) (i*100); System.out.println(j); O/P : 1732 //Expected:1732{As expected} Double i=15.33; long j=(long) (i*100); System.out.println(j); O/P : 1533 //Expected:1533{as Expected} I have tried to Google but unable to find reason.I am sorry if the question is trivial.

    Read the article

  • Detect double-tap on UISlider?

    - by Randy
    I can detect single/double-taps in specific views with: NSSet *myTouches = [event touchesForView:mySpecificView.view]; but I want to detect a double-tap on the button of a slider and can't find any reference to it. Is there a replacement for "touchesForView:" where I can enter the name of my slider? usage: I have three sliders with their default value being directly in the center of the slider. Once the position of the slider has changed, I want a quick way to individually reset each slider to its default position. I currently have each slider's containing view set to respond to a double-tap, updating each slider. It works fine, but doesn't seem natural. ie.I can't double-tap on the slider itself because the slider intercepts the taps and doesn't pass them on to the surrounding view. thanks in advance

    Read the article

  • Dividing a double with integer

    - by hardcoder
    I am facing an issue while dividing a double with an int. Code snippet is : double db = 10; int fac = 100; double res = db / fac; The value of res is 0.10000000000000001 instead of 0.10. Does anyone know what is the reason for this? I am using cc to compile the code.

    Read the article

  • ILNumerics multiply complex with matrix<double>

    - by nik
    I m looking at ILNumerics to translate some matlab code into c#. How would I multiply a complex and a double? Simplified description: In Matlab: A=[1 2 3] i*A*A' Returns a complex number. How would I do the same in ILNumerics: ILArray<double> A = ILMath.array(1.0, 2.0, 3.0); complex B = complex.i * ILMath.multiply(A,A.T); Throws the error: Operator '*' cannot be applied to operands of type 'ILNumerics.complex' and 'ILNumerics.ILRetArray<double>' Update This works: double C = 14.0; complex D = complex.i * C; But shouldnt: ILMath.multiply(A,A.T) also return 14.0?

    Read the article

  • Eclipse question - panels don't get restored when double clicking

    - by llm
    You know how, in Eclipse, when you double click on a file tab (which shows the class name), the editor gets expanded to the whole screen minimizing other panels? Well normally I just double click again on the tab to restore everything, but all of the sudden double clicking again doesnt do anything (the editor remains in full screen and all other panels minimized)! I am not sure what I did to cause this. Any ideas how to get it back to normal? Thanks.

    Read the article

  • Double.ToString with N Number of Decimal Places

    - by Ngu Soon Hui
    I know that if we want to display a double as a two decimal digit, one would just have to use public void DisplayTwoDecimal(double dbValue) { Console.WriteLine(dbValue.ToString("0.00")); } But how to extend this to N decimal places, where N is determined by the user? public void DisplayNDecimal(double dbValue, int nDecimal) { // how to display }

    Read the article

  • Double root folder vs single root folder

    - by Tomas
    On my Linux box, in bash, I have access to a "double root" folder denoted by two forward slashes: tomas:~ $ cd / tomas:/ $ ls bin/ cdrom@ ... tomas:/ $ cd // tomas:// $ ls bin/ cdrom@ ... The content of the folder and its subfolder is identical to the "normal" single slash root. The double slash does not go away when I access its subfolders. The annomaly does not repeat itself with three or more slashes; these are simple synonyms for the root: tomas:// $ cd home/tomas tomas://home/tomas $ cd /// tomas:/ $ cd //// tomas:/ $ What kindof place is it? Is it a bug? Can anyone explain the annomaly?

    Read the article

  • bash and arithmetic comparison: double quotes or not?

    - by Martin
    when comparing two integers in bash, do we have to put double quotes ? In the official document http://tldp.org/LDP/abs/html/comparison-ops.html I can read that double quotes should appear every time... But what is the differences in the following examples: [ "$VAR" -eq "1" ] [ $VAR -eq "1" ] [ "$VAR" -eq 1 ] [ $VAR -eq 1 ] As I am curious, a took a look at Ubuntu init scripts in /etc/init.d and there are many usage of arithmetic comparison in it, at least [ "$VAR" -eq "1" ] and [ $VAR -eq 1 ] are used... but it seems no one really "knows" what is the official way to do it. Thanks !

    Read the article

  • Avoiding double NAT with PPPoA connection

    - by user498429
    I've got an ASUS RT-N56U wending its way to me and have been thinking about how to set this up on my home network. I currently have a Netgear DG634g V5 and was hoping to use this device as a modem only, with everything else being done by the router. Problem is, my ISP uses PPPoA and the asus seems only to support PPPoE. I'm aware that a double NAT configuration should be avoided and I've seen some instructions here: http://www.tomshardware.co.uk/forum/33700-17-ultimate-modem-router-setup-thread Specifically, I was going to follow the guidance in the section entitled "Chaining Two Networks Together In a Cascading Fashion (Modem handles PPPoA)". That seems like it could work. However, is this a double NAT configuration or even a good way to do it? Would UPnP still work? The other option, I understand, is to buy the Draytek Vigor 120 but I'd ideally like to avoid the cost of that if its not necessary.

    Read the article

  • Can't double click files to open them in inDesign (CS5)

    - by Matt
    I cannot open a file unless I open inDesign (the program) and then do File-Open If I double click, it starts to open, then just hangs forever. AFTER I close it, and look in the directory where they're saved, I see a (temporary?) "lock" file. Now I can double click the original file and it opens just fine. However, now when I close iD it deletes the file and the whole process starts again... I have tried updating the software, uninstalled COMPLETELY and reinstalled, tried a brand new Win7 install. These files are all saved on a network drive, the computer is a new quad-core Dell with 12GB of RAM and a fresh x64 Win7 install on the SSD. Does not happen with other programs.

    Read the article

  • strod() and sprintf() inconsistency under GCC and MSVC

    - by Dmitry Sapelnikov
    I'm working on a cross-platform app for Windows and Mac OS X, and I have a problem with two standard C library functions: strtod() (string-to-double conversion) ? sprintf (when used for outputting double-precision floating point numbers) -- their GCC and MSVC versions return different results. I'm looking for a well-tested cross-platform open-source implementation of those functions, or just for a pair of functions that would correctly and consistently convert double to string and back. I've already tried the clib GCC implementation, but the code is too long and too dependent on other source files, so I expect the adaptation to be difficult. What implementations of string-to-double and double-to-string functions would you recommend?

    Read the article

< Previous Page | 7 8 9 10 11 12 13 14 15 16 17 18  | Next Page >