w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
error: cannot convert 'double (evaluator::*)(double, double)' to 'double (*)(double, double)' in assignment
This: double (*ope)(double, double); should be: double (evaluator::*ope)(double, double); // ^^^^^^^^^^^^ because you are using a pointer to member.

Categories : C++

Strange behavior when casting decimal to double
This is documented behavior. The decimal data type is more precise than the double type. So when you convert from decimal to double there is the possibility of data loss. This is why you are required to do an explicit conversion of the type. See the following MSDN C# references for more information: decimal data type: http://msdn.microsoft.com/en-us/library/364x0z75(v=vs.110).aspx double data type: http://msdn.microsoft.com/en-us/library/678hzkk9(v=vs.110).aspx casting and type conversion: http://msdn.microsoft.com/en-us/library/ms173105.aspx

Categories : C#

how to set double latitude and double longitude into array
You could make an internal class called LatLong or use simplelatlng public class LatLong { double lat; double long; public LatLong(double lat, double long) { this.lat = lat; this.long = long; } public double getLat(){ return this.lat; } public double getLong(){ return this.long; } } Then you could add this to MainActivity final List<LatLong> latLongList = new ArrayList<LatLong>(); public void onClick(View arg0) { //... double latitude = gps.getLatitude(); double longitude = gps.getLongitude(); latLongList.add(new LatLong(latitude, longitude)); //... }

Categories : Java

How to convert an ArrayList to a double[] array?
Ok just found a solution: double[][] returnvalue = new double[resultat.size()][resultat.size()]; for(int i =0;i<resultat.size();i++) { returnvalue[i] = resultat.get(i); }

Categories : Java

Sum an array of Func objects
Do you mean something like this? Func<double, double>[] l = new Func<double, double>[2] {(x) => x, (x) => x + 1}; Func<double, double> m = x => l.Sum(f => f(x)); For example, m(5) → l[0](5) + l[1](5) → (5) + (5 + 1) → 11.

Categories : C#

bind array of double to double*&
In this program a pointer an array is used: //#include <conio.h> #include <iostream> using namespace std; int main() { int a[5] = {1,2,3,4,5}; int b[5] = {6,7,8,9,10}; int (*pa[4])[5] = {&a,&b,&a,&b}; for(int i = 0; i < 4; i++) { for(int j = 0; j < 5; j++) cout<< (*pa[i])[j] << " cout<< " "; } //_getch(); cin.get(); } In some compilers comparison of &a and a is allowed. For example this code can be compiled in (old) Borland compilers: //#include <conio.h> #include <iostream> using namespace std; int main() { int a[20]; cout<< (a == &a); //_getch(); cin.get(); } and the output is 1. But in previous program instead of int (*pa[4])

Categories : C++

Strange behaviour when casting array char to array short
I would suggest to manually read out each element in your char array and build each pair of chars into a short. I know that there are probably faster methods, but you are implicitly stepping over the bounds of the type you have specific in the char array otherwise. Also, I would claim that my version is slightly easier to read in terms of your intent, albeit more kludgy. That is, something like this: IGNORE THIS FIRST CODE BLOCK... THIS IS WHAT HAPPENS WHEN I DON'T SLEEP! j=0; uint16_t temp; // recommend to use these types for portability for(i=0; i<8; i+=2) { temp = 0x0000; temp += (uint16_t)(char_array[i] << 8); temp += (uint16_t)(char_array[i+1]); short_array[j] = temp; j++; } Also, here's a faster method I came up with after thinking about the problem a bit m

Categories : C

Can a unit test perform double-duty by accepting a boolean value as a switch, or should I write two separate tests that duplicate the test code?
I don't like this. Here's why: your test method names should reflect the method under test, what the preconditions of the test are, and what you expect the result of the test to be: public bool AddCustomer_CustomerIsValid_ShouldReturnTrue() public bool AddCustomer_CustomerIsInvalid_ShouldReturnFalse() Now if you want to, you can refactor the core testing logic into its own method to eliminate the code duplication, and then call that method from the two above methods. But the refactored method is not a test case; it's just a helper method for the actual test cases. Example: [Test] public void AddCustomer_CustomerIsValid_ShouldReturnTrue() { var result = AddCustomerTest(true); Assert.IsTrue(result); } [Test] public void AddCustomer_CustomerIsInvalid_ShouldReturnFalse() {

Categories : C#

Find and search for a double in an array and return its indices? Is this an array element swap method?)
A few things to fix in your first example: Right now, j < circles[0].length means that only one column is being searched: column 0. You'll want j < circles[i].length to search every column by row. if (temp == r) means you're comparing a Circle and a double. I'm not familiar with the circle class, but I believe you'll want to replace instead of Circle temp = circles[i][j] with double temp = circles[i][j].getRadius();. You want to return as soon as you find the matching Circle, so you have some things a little backwards. With my new revisions, if (temp == r) will now activate the code if you have found the correct radius. That means below that if statement, you'll want return {i, j};. That will return the current circle's (which has the correct radius) indicies. The last statement wi

Categories : Java

Double Parse into an 2D array or jagged array
Here's your solution in JavaScript. note If your row values can contain quotes, new lines, or escaped delimiters more parsing is necessary. http://jsfiddle.net/N4YYA/ var result = []; var txt = document.getElementById("test").value; // get lines var lines = txt.split(";"); for(var i=0; i<lines.length; i++) { // get and trim whitespace off the line var line = lines[i].replace(/(^[s ]*|[s ]*$)/g, ""); var values = line.split(","); var row = []; for(var j=0; j<values.length; j++) { // get and trim whitespace off each value var value = values[j].replace(/(^[s ]*|[s ]*$)/g, ""); // add it to your row array row.push(value); } // add row to results result.push(row); } // debug show result var o = document.getElementById(

Categories : String

Using a switch with an array?
You insert the switch inside a foreach loop where you analyze every element of the array. $word_array is your array and $word is an element of the array. $word = $_POST["word"]; $word_value = 0; $word_array = str_split($word); foreach($word_array as $letter){ switch ($letter){ case "a": case "t": $word_value++; break; case "g": case "d": $word_value+=2; break; } }

Categories : PHP

Does double.IsInfinity(value) cover double.IsPositiveInfinity(value) and double.IsNegativeInfinity(value))?
Yes, the extra checks are redundant. As noted on MSDN for Double.IsInfinity: Returns a value indicating whether the specified number evaluates to negative or positive infinity

Categories : C#

accessing DB array key/value outside switch
It looks like the problem is that you are re-setting $x every time through the loop. The following would likely be a better solution: $getData="SELECT a_answer, q_ID FROM answers "; $result = mysqli_query($connected, $getData); $x = array(); // Added this. while($row = mysqli_fetch_assoc($result)) { $arAnswer = explode('|', $row['a_answer']); $arrayCount = count($arAnswer); switch ($arrayCount) { case 1: $q = $row['q_ID']; $a = $arAnswer[0]; $x[] = array($q=>$a); // Add [] after $x to push array($q=>$a) // onto the end of the $x array. // You can also use array_push, but // the technique here is quicker. break; }; }; Edit: To create a one-dimensional array, do the following: $x[$q] = $a; You

Categories : PHP

PHP - switch Array condition
$arr_user_group = Array(2, 5, 3, 5, 1); foreach($arr_user_group as &$group) { switch($group) { case 1: $group = 'Admin'; break; case 2: $group = 'Member'; break; case 3: $group = 'Ipsum'; break; case 4: $group = 'Lorem'; break; default: $group = 'Guest'; } } print_r($arr_user_group); Output: Array ( [0] => Member [1] => Guest [2] => Ipsum [3] => Guest [4] => Admin ) Note: As you are receiving the array from the database it would be better to create a new table (user_groups) with two columns: id and name. Then you can get the group name with a simple JOIN in your query.

Categories : PHP

php switch array key with subelement key
$out = array(); foreach ($arr as $key => $value){ $out[$value['user_id']]["num_products_user_by_ref"] = $value["num_products_user_by_ref"]; $out[$value['user_id']]["reference"] = $value["reference"]; } print_r($out); Your question showed a structure that doesn't seem to fit with your comment "Every user_id could contains more than 1 pair num_products_user_by_ref/reference." So, here's another version that allows for that possibility: $out = array(); foreach ($arr as $key => $value){ $entry = array("num_products_user_by_ref" => $value["num_products_user_by_ref"], "reference" => $value["reference"]); $out[$value['user_id']][] = $entry; } Output: Array ( [77] => Array ( [0] => Array

Categories : PHP

doubts using array and switch in?
c is an ascii character value (although stored in an integer type). e.g. character '0' is 48 in ascii, so if getchar returns character '0' then c will have the integer value 48. c - '0' does a subtraction of the two character values (ok, it converts '0' to integer 48 before subtracting), giving an integer ready to index into the array. So char '1' becomes integer 1, char '2' becomes integer 2, etc. It is just a quick way of converting from ascii character values to integer values, for a known set of values. It would have strange results for characters outside the expected range '0'-'9' - e.g. if you did this with character '+' you would get -5 which is not a good array index. However that is OK because the switch statement checks it is in the range '0' - '7'.

Categories : C

Using an array through a switch() statement in Javascript
You can try switching on a textual representation of the array. switch(sortedHand.join(' ')) { //Pair case '1 1 4 3 2': sortedHand.push(1,"Pair"); break; case '1 1 5 3 2': sortedHand.push(2,"Pair"); break; case '1 1 5 4 2': sortedHand.push(3,"Pair"); break; case '1 1 5 4 3': sortedHand.push(4,"Pair"); break; // etc. } As an alternative to specifying every case directly, perhaps build a function dispatch table using an object and get rid of the switch entirely. var dispatch = {}; // Build the table however you'd like, for your application for (var i = 0; i < 10; i++) { (function(i) { var hand = ...; // Add your hand logic here dispatch[hand] = function() { sortedHand.push(i, "Pair"); }; })(i); } // Execute your routine dis

Categories : Javascript

Switch case only displaying the first key in an array
You're using the wrong tool. The switch statement is designed to only select one condition. What you want is a whole string of individual if blocks. if (in_array("Design", $interests)) { echo "<h2>Design</h2>"; echo '<p><a href="http://dribbble.com" target="_blank">Dribbble</a><br/>'; echo '<a href="http://news.layervault.com" target="_blank">Designer News</a><br/>'; echo '<a href="http://beta.psdboard.com/" target="_blank">PSDboard</a></p>'; } if (in_array("Web Development", $interests)) { echo "<h2>Web Development</h2>"; echo '<p><a href="http://jqapi.com/" target="_blank">jQuery API</a><br/>'; echo '<a href="https://developers.google.com/s

Categories : PHP

Switch statement using string on an array
No, you cannot use the switch statement in C with the value of a string or character array. The closest alternative is to use some sort of data structure mapping strings to function pointers. The function pointer could be called after a string is used to look it up.

Categories : C

add key value to array strange behaviour
Your if condition i wrong, you are using single = to it should be if($categories['id'] == $selectedcategory ){ $categories['selected'] = 'true'; }

Categories : PHP

Strange array signature
Array subscripting in C is a bit strange. The standard defines E1[E2] as equivalent to *(E1+E2). Of course, addition is commutative, so this is equivalent to *(E2+E1). Which makes it equivalent to E2[E1]... With this in mind, your second line becomes: (&a)[0] = a+a; which you'll probably agree is equivalent to: *(&a) = a+a; or a = a+a;

Categories : C++

Strange UI behavior for {{#each}} on an array
I've revamped your code to return a cursor instead of an array, it may solve your problem but it's untested. var tagFilter=Session.get("tag_filter"); if(!currentTaskId || !tagFilter){ return null; } // find tags and fetch them in an array var tags=Tags.find({ taskId:currentTaskId, name:tagFilter }).fetch(); // build an array of Todos ids by extracting the todoId property from tags // see underscore docs var todosIds=_.pluck(tags,"todoId"); // return todos whose id is contained in the array return Todos.find({ _id:{ $in:todosIds } });

Categories : Meteor

Strange array syntax in PHP
See this question Both are valid, but could be changed to the square bracket notation you expected to see.

Categories : PHP

strange char array output in c++
s[0] is the 1st element of character array. &s[0] is the address of the 1st element, the same to the address of the array. Given the start address of a character array, std::cout prints out the whole string starting at that address, using the following overload of operator<< : // prints the c-style string whose starting address is "s" ostream& operator<< (ostream& os, const char* s); If you want to print the start address of the character array, one way is to: // std::hex is optional. It prints the address in hexadecimal format. cout<< std::hex << static_cast<void*>(&s[0]) << std::endl; This will instead use another overload of operator<< : // prints the value of a pointer itself ostream& operator<< (const void* v

Categories : C++

Strange warning when try to return array
Remove the * here: - (ABRecordRef *) findContactsContainingName: (NSString *) fname ^ ABRecordRef is already defined as a pointer.

Categories : Objective C

Strange array initialize expression?
In C99 you can specify the array indices to assigned value, For example: static char * name[] = { [3] = "bar" }; is same as: static char * name[] = { NULL, NULL, NULL, "bar"}; The size of array is four. Check an example code working at ideaone. In your code array size is 0x80000001 (its an hexadecimal number). Note: Uninitialized elements initialized with 0. 5.20 Designated Initializers: In ISO C99 you can give the elements in any order, specifying the array indices or structure field names they apply to, and GNU C allows this as an extension in C89 mode as well. This extension is not implemented in GNU C++. To specify an array index, write [index] = before the element value. For example, int a[6] = { [4] = 29, [2] = 15 }; is equivalent to int a[6]

Categories : C

What are those strange array sizes [*] and [static] in C99?
static in parameter array declarator void f(int a[static 10]); static here is an indication that parameter a is a pointer to int but that the array objet (where a is a pointer to its first element) has at least 10 elements. A compiler has then the right to assume f argument is not NULL and therefore it could perform some optimizations. gcc currently performs no optimization (source): "The information provided by static in parameter array declarators is not used for optimization. It might make sense to use it in future in conjunction with work on prefetching." qualifier in parameter array declarator void g(int a[cvr 10]); inside g a is a cvr pointer to int (cvr is const, volatile or restrict qualifier). For example, with const it means a is a const pointer to int (i.e., type

Categories : C

Strange array declaration in Java
According to javac from JDK7, it's invalid syntax (error: illegal start of expression pointing at the first [[). I assume it must be an error generating that page or some such.

Categories : Java

Double tr array
There are several ways to accomplish that, but one of the simplest is to order the data. First, you have to order your data how you like: SELECT cafedra.*, facultet.f_name FROM cafedra,facultet WHERE facultet_id = facultet.id ORDER BY facultet.f_name ASC ; Then in PHP sort it out: $data = array() ; foreach($row as $key => $value){ $f_name = $value['f_name'] ; if (!isset($data[$f_name]){ $data[$f_name] = array() ; } $data[$f_name][] = $value ; } And that output: foreach($data as $header => $rows){ $result = "<tr class='info'> <td colspan='5'>$r[f_name]</td> </tr> " ; foreach($rows as $row){ $result .= " <tr> <td class='span1' > $r[code] </td> <td

Categories : PHP

array.pop() and console.log() handing out strange results
This is a well-known issue. Although the console.log calls happen in the right order, the logging mechanism itself is reference-based and can cause this a lot often in Chrome and webkit based systems. The below is a work-around which changes it from reference to value. var array = [1,2,3,4]; console.log(JSON.stringify(array)); array.pop(); array.pop(); console.log(JSON.stringify(array)); Defect filed on the same: https://code.google.com/p/chromium/issues/detail?id=50316

Categories : Javascript

Strange class array issue - can't show it in jsp
You are getting the correct array the only problem is that you are printing the array, hence you are getting that output. If you want it to be printed in a beautified way then you need to override the toString method in your Menu class. As far as the usage of array, you have not shared any code but you can put a loop to iterate over that array and confirm that you are getting the values at the desired indices.

Categories : Java

java method accepts array of objects and a double then returns an array of objects
You need to create the array before you write to it. House[] lowPriceHouses = null; should be something like House[] lowPriceHouses = new House[houses.length]; you actually want a smaller array since, you might not need all houses.. It would be easier to make this a ArrayList and then convert it toArray before returning. for (int i = 0; i <= houses.length; i++) You want to do only < This is because when you have an array of size 10, the elements are indexed from 0 - 9. Thus accessing the element arr[10] will lead to issues.

Categories : Java

sorting a 2D double array
You have to implement the compare method, what you have there is just a template. It is unchanged because return 0 by default means the compared values are equal. Other return values are -1 and +1, based on the actual situation.

Categories : Java

VB.NET Array with Double Bracket ()()
It is a jagged array (an array of arrays). You can find more info at this MSDN article.

Categories : Dotnet

PHP: Strange effect when passing array into MongoCollection#insert()
This sounds like a bug related to https://jira.mongodb.org/browse/PHP-410 - can you please file a new bug at https://jira.mongodb.org/browse/PHP for this?

Categories : PHP

parsing diagonal double array
I would suggest that you make 4 passes, each one starting at a different corner. For example, given your array: intrepideg xtdcvmhgze yrwhoejkpn minusculet isnqdhivpi ntznyafhel ceamgnqgug erpoxtavrf gwaupsgwsd kyqtendrme Starting at the upper-left corner, you would search on the diagonal moving down from right to left. So: "i", "nx", "tty", "rdrm", etc. On the upper-right corner, search "g", "ee", "dzn", etc: the diagonal that moves down from left to right. Although that's more passes through the array, it makes for much simpler code than trying to search all four diagonals in a single scan of the array. You could potentially do it in two passes. After all, the search of the diagonal moving down from right to left is just a reversal of the diagonal moving up from left to right. So yo

Categories : C

Double array in php and javascript issue
If you want to pass arbitrary object or array from PHP to Javascript, you may want to try JSON. (untested) <?php $data = array('whatever'); $json = json_encode($data); ?> <script> var json = '<?=$json?>'; var obj = JSON.parse(json); // do with your obj. </script> PHP json_encode Javascript JSON.parse Note that it only works if your object/array does not contain any key/values containing the ' character. EDIT: It appears that you could have mixed up syntaxes. Javascript has no :: operator. I believe that objJS::importUsers( <?php echo json_encode($results) ?>); should actually be objJS.importUsers( <?php echo json_encode($results) ?>); However, as you don't tell us what objJs::importUsers is, we can just wild guess

Categories : PHP

Storing Polynomials using a double[] array?
It's not clear what the problem is. You create a class called Polynomial with a field called coefficients The IDE filled in all this code. I didn't have to write anything it is so trivial public class Polynomial { private final double[] coefficients; public Polynomial(double[] coefficients) { this.coefficients = coefficients; } }

Categories : Java

double array in cell, how to indexing?
here's a suboptimal way to go, it isn't memory efficient, but it is pretty straightforward: say that x=79,y=95,z=68 are the dimensions of your original cell array, and that each of them gives the same dimensionality ixj matrix (6 by 6). So first you can make a matrix out of the cell array: b=horzcat(a{:}); then we can reshape it to a 5-d array (this is just for pedagogical purposes) so you already have it ordered as (i,j,x,y,z)... c=reshape(b,6,6,x,y,z); then you can either work with c(i,j,x,y,z), or assign c to a cellarray: d=cell(6,6); for i=1:6 for j=1:6 d{i,j}=squeeze(c(i,j,:,:,:)); end end

Categories : Matlab

How divide all items in an array by a double?
There are two problems: You're not initializing normal (or indeed creating an array to populate) You're not specifying which element you're trying to set within normal So you want: double[] normal = new double[v.length]; for(int a = 0; a < v.length; a++) { normal[a] = v[a] / sum; } return normal;

Categories : Java



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.