w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Finding every possible "non-duplicate" combination given a set of 6 digits
Following code would display the combination for 4,5,6. You can change to include what ever value for (var i = 4; i < 7; i++) for(var y = i; y < 7 ; y++) for(var z = y ; z < 7; z++) $('#result').append('<div>' + i + '' + y + '' + z + '</div>'); IS this what you want. JSFIDDLE

Categories : Javascript

How to compare doubles with 5 digits of precision?
1.000001 when limited to the usual 64-bit IEEE floating point representation is actually 1.0000009999999999177333620536956004798412. Likewise 1.000002 is actually 1.0000020000000000575113290324225090444087. The two are ever more slightly apart than 0.000001. You can use a very slightly larger comparison value to catch this: const double epsilon = 0.0000011; It really isn't possible to completely eliminate any rounding problems with floating point numbers.

Categories : C++

Java: double: how to ALWAYS show two decimal digits
Use the java.text.NumberFormat for this: NumberFormat nf= NumberFormat.getInstance(); nf.setMaximumFractionDigits(2); nf.setMinimumFractionDigits(2); nf.setRoundingMode(RoundingMode.HALF_UP); System.out.print(nf.format(decimalNumber));

Categories : Java

(C++) std::istringstream reads up to 6 digits from string to double
The precision of your output probably just isn't showing all of the data in number. See this link for how to format your output precision.

Categories : C++

Format a double to two digits after the comma without rounding up or down
Math.Truncate(value * 100)/100 Although I make no guarantees about how the division will affect the floating point number. Decimal numbers can often not be represented exactly in floating point, because they are stored as base 2, not base 10, so if you want to guarantee reliability, use a decimal, not a double.

Categories : C#

Separate double number larger than 10 digits in Java
Perhaps you could use java.lang.Math.floor(double) for the integer part, and then subtract that from the original number to get the fractional part. (If that doesn't do what you want for negative numbers, then use Math.ceiling(double) for the integer part when the number is negative.)

Categories : Java

how to place a "double" formated to 6 decimal digits into a QString?
This is what I did to get 888888.888888: for(int i; i < m_iBuild; i++){ out << QString::number(dLog[i] - dLog[0], 'f', 6) << " " << msgList.at(cLog[i]) << " "; }

Categories : C++

c# double value displayed as .9999998?
According to the CLR ECMA specification: Storage locations for floating-point numbers (statics, array elements, and fields of classes) are of fixed size. The supported storage sizes are float32 and float64. Everywhere else (on the evaluation stack, as arguments, as return types, and as local variables) floating-point numbers are represented using an internal floating-point type. In each such instance, the nominal type of the variable or expression is either R4 or R8, but its value can be represented internally with additional range and/or precision. The size of the internal floating-point representation is implementation-dependent, can vary, and shall have precision at least as great as that of the variable or expression being represented. An implicit widening conve

Categories : C#

shift and rotation in matlab for handwritten digits
Let I be your image. %I = Input image; J = imrotate(I,30); %To rotate JS = [zeros(size(J,1),10), J]; %To shift 10pix horizontally figure,imshow(I) figure,imshow(J) figure,imshow(JS)

Categories : Matlab

Regular expression for Less or more than 9 digits Repeating digits for first 5 or all 9 digits and only number?
By your last comment, you need a regex to validate a string of maximum length 9 containing digits only: ^[0-9]{1,9}$ This will validate any string containing digits, with length at least 1 and not greater than 9. If you want to avoid strings such as 098 (leading zeroes), use this instead: ^[1-9][0-9]{0,8}$ EDIT: If I understand your question well now, you can use this regex: ^(?!([0-9])11-11)[0-9]{3}-[0-9]{2}-[0-9]{4}$ That is assuming that echosign can handle callbacks, if not, you can use this instead: ^(?!(?:111-11|222-22|333-33|444-44|555-55|666-66|777-77|888-88|999-99|000-00))[0-9]{3}-[0-9]{2}-[0-9]{4}$

Categories : Regex

Double being displayed with unnecessary zeros after decimal
As mentioned in the [NSString stringWithFormat:] class reference: Parameters format A format string. See “Formatting String Objects” for examples of how to use this method, and “String Format Specifiers” for a list of format specifiers. This value must not be nil. and following the first link, one of the first examples is: NSString *string1 = [NSString stringWithFormat:@"A string: %@, a float: %1.2f", @"string", 31415.9265]; // ^ // string1 is "A string: string, a float: 31415.93" You need to learn to think for yourself. Read the documentation!

Categories : Misc

How do I compare the display layout of two pivot tables displayed next to each other
Based on Excel 2007, copy your two PivotTables and Paste Special values somewhere convenient. You will lose the drill down facility and the ability to choose different views (without going back to your originals) but should be able to insert cells to align rows to suit.

Categories : Excel

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++

sql server 2008 r2 compare int with double
Try this one - ALTER PROCEDURE dbo.getRestaurantNear ( @lat INT , @lon INT ) AS BEGIN SET NOCOUNT ON; SELECT ID , restaurantID , [description] FROM dbo.RestaurantAddressMap WHERE ROUND(lat, 0) = @lat AND ROUND(lon, 0) = @lon END

Categories : Sql Server

compare double in hibernate criteria
You should use Double instead of double in the mapped class. private Double ball; It will be useful if you have NULL in the database as well.

Categories : Hibernate

How to implement double compare and swap in C/Linux?
I don't know of any CAS operations that work on two distinct memory locations. However, it's possible the paper is using a struct for the pointer and counter as a workaround to treat both fields as a larger type, and therefore, change both atomically. Assuming you have a struct of two fields, a pointer and a counter: pointer size of 4 bytes, counter size of 4 bytes; properly aligned without padding to a struct size of 8 bytes. Assuming you also have a CAS operation that handles values of 8 bytes (such as a pointer to a 64-bit integer). You can prepare the struct values separately, and use the CAS operation on the struct as a whole to change two values at once.

Categories : C

Why does time difference measurement with `std::chrono` give more significant digits with `float` type, compared to `double` type?
You want to read up about binary floating points and precision! float has 6 decimal digits of precision, double has 16 decimal digits of precision (I think but I keep misremembering the exact values; check std::numeric_limits<T>::digits10). Since binary floating points can't representation fractional decimal values exactly (only some but many not), printing the binary floating point values causes some rounding when leaving the printing routine to do what it wants to do. When you ask for more than digits10 digits, the rounding will generally be put off and it prints the actual binary fractional value up to whatever number of digits you asked for. In the case you described above the float version just starts printing the actual values (which can have up to std::numeric_limits<T>

Categories : C++

How to Compare two Chanel s in Matlab
The way you have defined s1 and s2, it is not possible for the signals to be equal. Should you still want to test with matlab, however, and assuming you know nothing a priori about the signals, FFT both (as explained in my answer to your previous question here), and compare the frequency and amplitude of the peaks (and if you wish, phase).

Categories : Matlab

Does clang support a double-word-compare-and-exchange operation?
The issue here is that SOME models of 64-bit processors do not have a cmpxchg16b. The -mcx16 tells the compiler that "I know that this processor supports the cmpxchg16b instructions, so you can generate it". This is to avoid problems with older 64-bit processors which don't support this instruction - they would then cause an "illegal opcode trap". It's the same thing as using for example SSE4.

Categories : C++

Duplicate photo searching with compare only pure imagedata and image similarity?
You can remove exif data with mogrify -strip from ImageMagick toolset. So you could, for each image, copy it without exif, md5sum, and then compare md5sums. When it comes to visually similar messages - you can, for example, use compare (also from ImageMagick toolset), and produce black/white diff map, like described here, then make histogram of the difference and check if there is "enough" white to mean that it's different.

Categories : Image

Avoid duplicate activity or fragment due to multi-touch or double tapping?
I have solved it by adding this to our parent Activity class: private Intent mActivityStarted = null; [...] @Override public void startActivity(Intent intent) { if (mActivityStarted == null || mActivityStarted == intent) { mActivityStarted = intent; super.startActivity(intent); } } @Override public void startActivityForResult(Intent intent, int requestCode) { if (mActivityStarted == null || mActivityStarted == intent) { mActivityStarted = intent; super.startActivityForResult(intent, requestCode); } } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { mActivityStarted = null; super.onActivityResult(requestCode, resultCode, data); } I also added this in our parent Fragment class and it share

Categories : Android

How does matlab compare two complex numbers?
The complex numbers are compared first by magnitude, then by phase angle (if there is a tie for the maximum magnitude.) From help max: When X is complex, the maximum is computed using the magnitude MAX(ABS(X)). In the case of equal magnitude elements, then the phase angle MAX(ANGLE(X)) is used. NaN's are ignored when computing the maximum. When all elements in X are NaN's, then the first one is returned as the maximum.

Categories : Matlab

compare multiple matrices matlab
edit As I did not know about the second argument of the max-function, here is what you should NOT use: old Well, quick&dirty: x=[2 5 8]; w=max(x) [~,loc] = ismember(w,x)

Categories : Matlab

How to vectorize double loop in Matlab?
You are probably looking for the meshgrid function. It is designed to fill in the sort of m by n combinations that it looks like you need. For example: >> m = 1:4; >> n = 1:3; >> [mGridValues, nGridValues] = meshgrid(m,n) mGridValues = 1 2 3 4 1 2 3 4 1 2 3 4 nGridValues = 1 1 1 1 2 2 2 2 3 3 3 3 This is a little more complicated since your inner loop depends on the value of your outer loop. So you will need to mask out the undesired [n, m] pairs (see below). Modifying the prototype code that you have provided, you would end up with something like this: [mValues, nValues] = meshgrid(0:variable, 0:variable); %Start with a full combination of values mask = mValues

Categories : Matlab

Double sqrt solution in Matlab?
The docs don't say anything specific about always only providing the positive square root but it does seem like a fair assumption in which case you can get the negative square pretty easily like this: p = sqrt(1-cos(a)^2); n = -sqrt(1-cos(a)^2); btw assigning to sin(a) like that is going to create a variable called sin which will hide the sin function leading to many possible errors, so I would highly recommend choosing a different variable name.

Categories : Matlab

Vectorizing double for loop in Matlab
Pairwise Euclidean distance using pdist, which does the heavy-lifting in C, and squareform to create the distance matrix: d = squareform(pdist(A.')); If you need this to be even faster (365-by-365 is not very big though), see my answer here or try this File Exchange program.

Categories : Matlab

Why is find in matlab returning double values
I can only guess, but probably because a wide range of functions only support double. Run setdiff(methods('double'), methods('uint32')) to see what functions are defined for double and not for uint32 on your version of MATLAB. Also there is the overflow issue with integer data types in MATLAB that can introduce some hard to detect bugs.

Categories : Matlab

Record video with web cam and get first frame of that and compare it with next frames in matlab
imread is used to read a file from a folder which is already in a particular compressed or uncompressed format. In your case, you have raw data, on which you can perform operations. So, try using: camfrm1 = rgb2gray(camfrm1); This should work. There is a second typo: bt = abs(double(camfrm2)-double(camfrm1));

Categories : Matlab

How to Convert Persian Digits in variable to English Digits Using Culture?
You need to parse them first, using e.g. Int32.Parse() with the correct cultural specifier. Once you have it as a plain integer, it's simply a matter of calling ToString() on it, again with the correct cultural specifier. An alternative solution is to walk the string character by character and just replace any character that is a Persian digit with the corresponding (west) arabic numeral. Other characters can then be preserved as-is, if required. If the string really contains a number, you should go with the integer parsing method. If it is not just a number, but really a phone number, serial number etc, you might need to use the replacing algorithm instead.

Categories : C#

Computing float to 2 digits only (not formatting/rounding off 6 digits after decimal to 2)
There is nothing you can 'tell' math.h (in this regard); float does not have precision options. If you want less computational intensive calculations you must use other types or methods. You already mention the best candidate: fixed-point. But, for obscure reasons, you say that you can't use it. Other idea is to scale up your calculations by for example a factor 10,000, and keep everything as int (or longer). Then, only scale down to float when needed. But of course, it depends on your problem if you can do this.

Categories : C

matlab Conversion to double from cell is not possible error message
You can probably fix it with this: plot(datenums,[everglades_precip_data{:}]); or this: plot(datenums,cell2mat(everglades_precip_data));

Categories : Matlab

data type to store precision more than double in matlab
It appears that matlab only uses 64-bit doubles, but you might have luck with one of the arbitrary precision libraries available for matlab.

Categories : Matlab

Regular expression match a-alphanumeric&b-digits&c-digits
you can use this pattern : ^(?i)a-([0-9a-z]++)&b-([0-9]++)&c-([0-9]++)$ In the case what you try to match is not the whole string, just remove the anchors: (?i)a-([0-9a-z]++)&b-([0-9]++)&c-([0-9]++) explanations: (?i) make the pattern case-insensitive [0-9]++ digit one or more times (possessive) [0-9a-z]++ the same with letters ^ anchor for the string start $ anchor for the string end Parenthesis in the two patterns are capture groups (to catch what you want)

Categories : Java

Why is a double always 8 bytes and an int always 4 bytes, even if the int has more digits?
These primitive datatypes need to be defined somewhere for you to use them. It is not a flexible container where you can stuff in whatever you want, rather more like a bottle which takes the same space no matter if full or empty. And they also have a maximum they can contain. Read more yourself here.

Categories : Java

How to Combine groups of duplicate and repeating values and preserving order? Matlab
You can use a derivative to find fluctuations in your data arrays, which would indicate a change in grouping. Anywhere where the derivative is not 0, there is a change, either positive or negative. Find where these changes occur, and then grab the corresponding indices. Something like below. data = [1;1;1;2;2;2;3;3;3;4;4;4;4;4;3;3;2;2;2;2;1;1;1;1;4;4;4;4;]; change = diff(data)~=0; indices = [1,find(change)'+1]; compressed = data(indices)'; and the result will be compressed = 1 2 3 4 3 2 1 4 And of course you can use the indices variable for whatever you need as well. Note On the third line, we add index 1 because technically the start of the array is a change, and then we add 1 to the find command because we are using find on the derivative, so the r

Categories : Matlab

Matlab Undefined function or method 'C' for input arguments of type 'double'
You've to do either of following a) pass C as argument to function simps() OR b) evaluate C from workspace C = evalin( 'base', 'C' ); inside the function before its use. Also, use of eval and evalin is generally discouraged as it makes your code harder to follow and re-use. Tip : You may want to combine both like following function simps(C) if nargin == 0 C= evalin( 'base', 'C' ); end % Your code

Categories : Matlab

remove last 14 digits from string, if there are digits
this? $filename = "data-c(festo1-small1);divider-bin-1.4.4;divider-conf-1.3.3-w(1,16);storage-bin-1.5.4;storage-conf-1.5.0-w(1);worker-bin-4.5.1;worker-conf-4.4.1-c(festo1)-win1_20130620123306" $filename -replace 'd{14}$'

Categories : Powershell

Display more digits of p-value digits from adfTest when p-value<0.01
I don't know much about the command you're running, but I looked through the adfTest function and it looks like the do approximation of the p-value based on the approx function and a table of critical values, which means that they can't report P-Values < 0.01.

Categories : R

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#

show 2 digits max after floating point ... only if it is a float number with more than 2 float digits
I think there is no such short bypass for it. Manually check if it has 2 or more digits after decimal. How to know if it has less one or zero digits after decimal ? Just multiply with 10 and check if it is an integer. If it is, print the number as it is. If it's now use '%.2f' to print it.

Categories : PHP



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