Most voted "numbers" questions
Number is a mathematical object used to describe quantity, order or measure.
Learn more…30 questions
Sort by count of
-
34
votes15
answers4487
viewsDetermine if all digits are equal
It takes as a parameter a numerical value. For example, 888 or 546. And I have a function that returns a value one boolean true if all numbers are equal, or false if they are different. How do I…
-
13
votes2
answers1270
viewsWhy is the NAN constant evaluated as True when testing it with is_numeric?
I was doing a test with the constant NAN in PHP, because until then I had never used it. I did tests out of curiosity. I noticed something interesting. When calling the function is_numeric in NAN…
-
11
votes2
answers8942
viewsHow to verify if a variable is float, decimal or integer in Javascript?
I tried with typeof(), but it only returns to me if it is a number, string, etc.. It would be something like that: var x = 1.2; if (x == inteiro){ alert("x é um inteiro"); }…
-
7
votes2
answers241
viewsIs there a difference between Number and parseFloat?
When I need to turn a string into a number in Javascript, I can use both the object Number as the function parseFloat. Example: var numero = "1.5"; console.log(Number(numero));…
-
6
votes1
answer2170
viewsWhat does 1e+24 Chrome console mean?
I noticed that when I type in Chrome console 1000000000000000000000000 he returns me 1e+24. And when I type 1000000000000000009901591 he also returns to me 1e+24 whereas 1000000000000000000000000 is…
-
6
votes4
answers3497
viewsHow to prevent the user to enter numbers for a given data?
How do I make my Java program not accept numbers as given by the user? I would like, in a field that requires the user name, if a number is inserted, such as a badge, make the program ask again for…
-
6
votes3
answers194
viewsWhy does isNaN(null) return "false"?
I came across a situation where undefined and null return a different value to the function isNaN, while I hoped they would both return true (are not numbers). In the example below I also put a…
-
5
votes2
answers728
viewsHow to separate numbers from three to three, backwards, in Javascript, without regular expression?
I already know how separate the numbers from three to three, backwards, with regular expression in Javascript. But I wonder if in Javascript there is a simpler solution, and without the use of…
-
5
votes2
answers3090
viewsFunction that returns the smallest prime number in Python
I was writing a Python code that received a number and returned the first prime number smaller than or equal to that number. I created a function called maior_primo, which does the following:…
-
4
votes2
answers1760
viewsHow to format monetary values with C++?
I would like to present values formatted as currency, with thousands and cents separators. I would like for example, 56000/12 present 4.666,67. I can present 4,666.67. Would there be some way to…
-
4
votes3
answers1175
viewsUsing Double in the compareTo method
I’m having a doubt. I have several methods of comparison, however, one of the attributes used to make the comparison is double. Then an error occurs: Cannot invoke compareTo(double) on the Primitive…
-
4
votes3
answers691
viewsHow to correctly format a monetary value?
I have a value that comes from the form that way: R$ 1.500,95 I need him to stay that way: R$ 1500,95 How to turn him into the second way? I need him to look completely the same as the way he was…
-
4
votes1
answer112
viewsWhy does Python have such big numbers?
What would be the largest number in python? Python shows the result of expressions like: >>> 8**150000 The result was 135465 digits! I wanted to know the language can do this.…
-
4
votes1
answer166
viewsMath.Running defining minimum and maximum values other than 0
I’m trying to set the minimum and maximum value, using Math.random() * (max - min) + min;, for example, informing on the Html page the minimum = 10 and the maximum = 20, but the results are always…
-
4
votes1
answer77
viewsWhy does the Math.toRadians method return an inaccurate value?
I was programming a method in which I needed to convert a value from degrees to radians and I wondered if this conversion no longer existed in Java. Searching the Internet I discovered the method…
-
3
votes4
answers857
viewsCompare if variable is number within an if
Having var chute = Math.round(parseInt(prompt("Adivinhe em qual número estou pensando"))); var numeroPensado = Math.round(Math.random() * 100); if(chute != numeroPensado){ document.write("Que pena,…
-
3
votes1
answer105
viewsHow does the use of other numerical bases in C#work?
When I was learning the basics of variables in C#, I learned that the whole numerical statements (Int32) used the numerical base 10, which is what we use most commonly in our day to day life. A…
-
3
votes1
answer88
views -
3
votes2
answers84
viewsIs there a difference between "accuracy" and "precision" in computing contexts?
Recently, appeared on the site a question which deals with "inaccuracy" of the value returned by the method Math.toRadians Java. However, in other places (such as in the answers of this question),…
-
2
votes1
answer913
viewsInfinite counting of ordinal numbers and exposing in HTML document
What I want to know is how I can make a rising counter in pure Javascript 0 , 1 , 2 , ... I want something automatic, infinite without needing an arrow an integer or negative number Counting can…
-
2
votes1
answer95
viewsWhen a calculation is made in C#, is the primitive type of the variable maintained in the result?
I’m creating a simple C# application to calculate some flight information, in which you have a class called Calculator containing the following methods: public static float GetDistance(ushort…
-
1
votes2
answers86
viewsHow would you solve this simple question?
I was solving a simple Python question The program asks for three numbers and returns in descending order - I decided to do it using a list, like this: numeros = [] for i in range(0,3):…
-
1
votes2
answers170
viewsConvert a string in monetary format to number and subtract 90%
How can I convert a string to number and subtract 90%? I tried to make a code (below), but it returns the value 3205.5 and I’m not getting to know why. If I use the value R$ 320,50 works. var a =…
-
0
votes2
answers189
viewsHow to test if a string is a number in the C language?
I’m a beginner in programming. I am performing an exercise in which I must determine whether a character string is a number, considering that the user can write anything as input. So I created the…
-
0
votes1
answer67
viewsEntire division returning a different result than expected
I’m having a problem with the entire division in python and R. The language returns a value other than "correct" in the entire division of 327 by 3.27 and the rest (%) different from 0 in these…
-
0
votes1
answer50
viewsValue placed in "define()" is not displayed correctly
Well personal, I am writing a system of "versioning", I have a class that collects and compares some information. In index of my project I pass the current version of the system and in the…
-
0
votes2
answers860
viewsCheck if number is equal to the sum of squares of 4 consecutive prime numbers
I need to do a program where I type a number and the program checks if it is the sum of the square of 4 consecutive primes. Example: 2020 has to give 17 2 + 19 2 + 23 2 + 29 2 My code for now is…
-
0
votes0
answers40
viewsHow to format a number using "toFixed" only if it is not integer in Javascript?
I have a function that returns me a number, which can be integer, like: 440; or it can be broken, like 466.1638231521. But I need to have a way to, from the function, find out if the number is…
-
-3
votes3
answers65
viewsEternal and unique value
That’s not a problem, it’s a question, so I hope you can help me. I’m a beginner in python, and I’m learning about lists, and the teacher talks about unique, timeless elements. I wanted to know the…
-
-3
votes1
answer71
views