Posts by Maniero • 444,682 points
6,921 posts
-
12
votes4
answers1015
viewsA: Problem with pennies when using the Biginteger type
Use double or float To represent money is to ask for trouble and cause harm. These are types with the binary fractional part and cannot represent all possible values. These types are great where…
-
8
votes3
answers14329
viewsA: How to use the C++ vector class?
For these things it is always interesting to consult the quasi-official documentation and then ask more specific questions than you didn’t understand with a real example of what you’re doing. One of…
-
5
votes2
answers232
viewsA: Power method and exception treatment
It’s all right, just throw the exception before you run the calculation. Usually when the requirement is to validate the parameters the first thing you do is to use one or more ifs with the…
-
4
votes2
answers679
viewsA: Use of instanceof
Just create an accountant: import java.util.*; class InstanciaDe { public static void main( String[] args ) { int contaF = 0; int contaJ = 0; ContaF Rafael = new ContaF(); ContaJ Roberto = new…
-
1
votes1
answer337
viewsA: How to create an abstract class in C++?
I don’t know if it’s the only problem, but besides the file names being reversed in the question, the abstract class is called Tetes and then Tetes1 is inherited from Teste. You already have a…
-
3
votes3
answers1110
viewsA: Multidimensional array of different types
Usually this is solved by creating a class to contain these two columns and then you put objects of these class in the list. It is a container within another, first puts into a simple data…
-
3
votes2
answers198
viewsA: How to create variable to contain a number with millions of digits?
Although it is technically possible to put the number into a variable, this is hardly done. Usually allocate it to memory and the variable just points to it. At least this would be necessary if you…
-
2
votes1
answer156
viewsA: Major algorithms of sorting?
The question is a little wide and putting their code would be too much, because it would only be an implementation. The Quicksort is fired the most used because it meets almost all situations well.…
-
2
votes2
answers590
viewsA: How does creating an Array work?
You’re using the constructor yes. It’s something internal, the syntax is a bit, but at the bottom you’re using a constructor. int[] a = new int[10]; If there were no proper syntax in the language,…
-
1
votes2
answers1435
viewsA: Maximum size for stored procedures, Fields, etc... in Firebird
I really didn’t find official documentation. The handle limit in Firebird 2.5 is 30 characters (or 31 seconds some sources). Although it is not official, is what says various responses on forums and…
-
14
votes2
answers4807
viewsA: When should I use the class attribute in HTML elements?
He is a grouping. Whenever you have HTML elements that deserve to be grouped in a certain way, you can use a class to indicate that everyone has something in common. Of course, this only makes sense…
-
3
votes1
answer9873
viewsA: How to create a class with attributes and methods in C++?
The example posed in the question (after editing) indicates a fundamental difference between Java and C++ (C does not allow classes). The declaration of the data structure is usually made separate…
-
2
votes3
answers1406
viewsA: How to change a value of a variable inside an if in java?
You almost got it right. It’s a middle ground between the two. It seems that the solution would be this. I just don’t guarantee it because I don’t have the whole context. You may have an even better…
-
2
votes1
answer146
viewsA: Keep variable value between layers of a function
Organizing the code always helps, it’s very easy to fool where each if close, it’s a nightmare to give maintenance in code so I lost several minutes to understand what you’re really doing and I have…
-
6
votes1
answer1565
viewsA: How does it work and what is the syntax of the machine code?
Trying to answer superficially, this is a file in a certain format, as well as there are database formats, texts, spreadsheets, images, etc. This is a format that the operating system recognizes and…
-
8
votes1
answer753
viewsA: Programming language that does not require prior installation
Almost all compiled languages are exactly like this, you create the program, compile, generate an executable and can send it to the person. Whether you will have to do an installation of this…
installationanswered Maniero 444,682 -
7
votes2
answers289
viewsA: Numbers with zero start in Javascript
If it is number, pass 214 (without zeros). Numbers starting at 0 use octal notation, not decimal. 214 written in octal equals 140 written in decimal, so you see one thing that the computer…
-
3
votes1
answer416
viewsA: How to implement the Observer standard in practice, with database?
The question doesn’t go into too much detail, it’s too generic, so I can’t give a very precise answer, but basically the standard Observer is applied in database using the triggers feature. Every…
-
9
votes3
answers1915
viewsA: Remove element from a vector in C# and don’t leave the vector with a blank space?
It doesn’t work efficiently. You can do this: var array = { 1, 2, 3, 4, 5 } array = array.Where(item => item != 3).ToArray(); //retira o 4o. elemento If you don’t want to use LINQ: var array = {…
-
7
votes2
answers334
viewsA: How to protect an Assembly from decompilation?
First of all read this: How to protect source code? Protecting intellectual property There really is a certain exaggeration in thinking that people will decompile and reuse the code. It’s not that…
-
5
votes2
answers86
viewsA: Is it safe to use Javascript’s String.Concat method in current browsers?
This method has no security problems, is long supported by browsers. I think it’s weird to use it in concatenations. Obviously the operator can do weird coercion, but that’s another problem. My code…
-
2
votes1
answer81
viewsA: How to set Title in a`img`?
This can be put on code Behind thus: this.ProximoMes.Attributes.Add("title", "Alguma coisa aqui"); I put in the Github for future reference.…
-
3
votes2
answers634
viewsA: Start multiple threads in a repeat command
You are playing everything in one variable. If you want to insist on this form, you have to play elements of a array or list, so each thread will be in a variable. But read my comment. If you’re…
-
3
votes2
answers804
viewsA: Generate text file from a console application
Take out all parts of Windows Forms. The name of the file that is coming from saveFileDialog.OpenFile() will be replaced in general by (for example): new FileStream("caminho do arquivo aqui",…
-
10
votes1
answer947
views -
4
votes1
answer179
viewsA: Problem with boolean checks in Javascript
Javascript '0' is defined as true (anything that is not false, 0, "", null, undefined or NaN, is true). So the first expression denies a true one and therefore does not execute the command of the…
-
9
votes4
answers543
viewsA: Variables operating in more than one method
The problem is that it is creating a new instance in each operation. I would do it another way, but if you’re going to do it that way, at least always use the same instance to preserve the values.…
-
2
votes4
answers1276
views -
7
votes4
answers2291
viewsA: How to do a search inside this vector of objects?
It is not easy to answer definitely only with this excerpt, but probably I would change it: public boolean pesquisar(String nome) { for (int i = 0; i <= qtd; i++) { if…
-
2
votes1
answer833
viewsA: Optimization game Bulls and Cows
What you can do is improve code organization, don’t lump it all together and don’t write every hour in a way. Other than that it can do little, as far as I understand. Can transform num from 1 to 4…
-
6
votes2
answers1863
viewsA: What is the purpose of the default when used in the signature of a method?
Java 8 allows calling default methods. They are methods whose implementation may already be available on the interface (which could not happen before). So all classes that implement this interface…
-
16
votes2
answers2701
viewsA: Which is more secure: Session or cookie?
Safe is doing right. It is mastering the subject, knowing all the possible vulnerabilities of each mechanism, knowing when and for what it can be used. Depends on each case. Are you using SSL? This…
-
7
votes2
answers105
viewsA: What would be a parameter call before the string in a function
This is not parameter, the parameter is the $logger. What comes before, the LoggerInterface, is the type of the parameter. That is, PHP will only accept a call to this method if an argument of this…
-
1
votes1
answer1470
views -
13
votes5
answers12645
viewsA: How to create a vector without determining its size in Java?
Simple, use a ArrayList. The array Java can only have fixed size. There are other options, but almost always this is the best. I’d wear it more or less like this: ArrayList<Teste> t = new…
-
3
votes2
answers97
viewsA: Does user traffic imply monthly value?
Directly the amount of users will not affect anything, what affects is the traffic generated by them. So if 1 user traffic 1GB is what will affect. If 100,000 users traffic 1KB each, these users…
windows-azureanswered Maniero 444,682 -
2
votes2
answers866
viewsA: Char pointer or char array?
The array of char can give better performance, after all will avoid a dynamic allocation of memory, which is something relatively expensive. No matter if the size will be determined at build or run…
-
4
votes2
answers436
viewsA: Delegates and methods
The delegate is assigned to a variable or passed as argument of a method (which will arrive in a variable), or as return. It is not possible to do this with a normal method (it even gives but not in…
-
3
votes1
answer839
viewsA: Error when reassembling a string. Size is out
The expression i.LastIndexOf("\r") is not finding the character sought. When what is being searched within the string is not found the return of this method is -1, as documentation. Then you can…
-
6
votes2
answers119
viewsA: What is the name of these parameters in ASP.NET MVC?
These constructions are attributes, are not parameters. Part of the syntax is C#. The attribute is just information, called metadata. It alone does nothing. there needs to be a mechanism in the code…
-
5
votes4
answers1407
viewsA: How to work with values that far exceed the long (64 bit) limit value
In Java use the class BigInteger. She has arbitrary size. In C you will have to choose a non-standard library or implement on your own. A Gmplib has a known implementation. Multiplication occurs by…
-
6
votes1
answer308
viewsA: How to cast exception in SQL and treat in C#
You can use the RAISEERROR with a severity level of at least 10 (smaller numbers do not cause exception). This will produce an exception in C# that can be captured by SQLException.…
-
5
votes2
answers515
viewsA: Are Ltenatives for complex conditions in a lambda expression?
First, it is using only one condition expression. The fact that it has sub-expressions does not make it have multiple conditions. The condition remains unique. It doesn’t seem hard to read. Do you…
-
8
votes3
answers488
viewsA: What is the 'do' statement’s function?
Does nothing :) It starts a block of commands that must be executed together. The block is obviously finished by end. It is very common to use with command such as: if (actually uses the then in…
-
18
votes4
answers2408
viewsA: What is buffer overflow?
If you used it once, saw the warning and kept using it, you’re making a mistake. Buffer overflow The function gets() receives a variable that functions as a buffer. That is, a variable is created…
-
4
votes1
answer298
viewsA: What are the differences between Friend and Static classes/members?
A friendly member does not belong to an instance of the object, that is, can not access by this, the access will be through a parameter explicitly declared. The friendly member only delegates access…
-
11
votes1
answer1119
viewsA: Rounding of 5 cents
You have to normalize at the point you want. If you want every 5 cents you divide the value by 0.05 rounding it and then multiply again by 0.05 (5 cents), so you return to the original value without…
-
11
votes2
answers1242
viewsA: How to multiply an "X" character as many times as you want?
Yes, there is, just build the string indicating the number of times you want: var texto = new String('P', 5); Behold working in the ideone. And in the .NET Fiddle. Also put on the Github for future…
-
14
votes2
answers21117
viewsA: What does "Return" do in Python?
As in any language mainstream, the return ends the execution of the current function, returning exactly to the point where it was called. Eventually it can return a value as a result of the…
-
10
votes1
answer521
viewsA: What are the advantages of using directives and macros?
They in themselves do not influence anything in performance. The specific use of some technique with them may even bring some result. At first there was only the preprocessor to accomplish a few…