This question already has an answer here: Why null in javascript is bigger than -1, less than 1, but not equal (==) to 0? what is exactly then? 2 answers I was on Codewars trying to complete some of the tasks and one question asked Create a toDense() function...

If I wanted to make an add method that adds values of two different types like: add[T,S](op1: T, op2: S): ? = ... The most notable example I can think of are the basic number types. If I add a Byte and an Int then it would return an Int....

let's say I have a string contained numbers, and I need to check if it's in specific format where would be every thousand separated by a space, followed by "," and 2 digits with decimals. So for example, 20125,33 would be like 20 125,33 122000111,15 would be like 122 000...

I'm trying to modify a script that generates random numbers to filenames and instead have a pretty increasing counter of +1 each new file The original function is very simple it looks like this: $name .= generateRandomString(5); What I've came up with my mediocre skills is: $name .= $count =...

I noticed that if i use the leading zeros are not removed. I also saw a lot of discussion on how keeping leading zeros. For example "000023" and "23" are the same number and i think that it doesn't make sense keeping those zeros....

I am taking a crack at Android development and for my first app.. pun intended, I decided to go with a calculator. So my problem is that any arithmetic operator is evaluated as a numeric datatype and crashes the app. I've seen this discussed on other forums but most of...

Lets say I have a following array of numbers: 1,5,500,994,6950,54,54,845,101,54046506452,5980,960406,55,680,68045,66540,321032 What is the most size efficient way to transfer it with http post to a website which decodes it back to numbers? If I transfer it as text "1,5,500,994,6950,54,54,845,101,54046506452,5980,960406,55,680,68045,66540,321032" then every 1 digit and separator take 1 byte which is...

sorry if this is an confusing post and the style is not proper but this is my first question but im having an error after i want to fetch c_latlong : the things he will fetch are: LAT value : 50,9459744669855 LON value : 5,9704909091251 ORA-01722: invalid number ORA-06512: at...

I have problem with inserting a bit in number. I have a position where to insert this 1 bit. For example if i have a number 186 (represent in bits: 1011 1010) and I have a position 4. It will looks 1 0111 1010. And my second problem is almost...

Hello I want to do a really simple thing. Just make a template function for any numbers. I actually want as little as ability to "add". In C++ it would be really trivial like this: template <typename T> inline T add (T a, T b) { return a + b;...

I want to pre-parse a json an convert all numbers in the json (integers or float) to strings. For example: { "integer": 10000, "big_integer": 100000999499498485845848584584584, "float1" : 1.121212, "float2" : 8.226347662837406e+09 } to this: { "integer": "10000", "big_integer": "100000999499498485845848584584584", "float1" : "1.121212", "float2" : "8226347662.837406" } Update I have found...

I am working on something. I got to check a string for validation. This string has a country code and a university code (from their own tables in the database) and a bunch of numbers. Now I need to validate this string. I need to check this string on the...

I want to extract numbers from a string like: str="good_mor9ni13ng_23guys "; The output should be an array [9,13,23]. How should I proceed?...

Imagine a number 10, then after user clicks a button it changes to 100. But how to make an efficient transition 10 -> 100, that will display values like 12, 15, 18, ..., 97, 100 over 1 second. I've seen something like that in "Cookie clicker" but couldn't find anything...

I was writing a small program to compare speed between CPP and Matlab, and I noticed I was getting the wrong answer when working with large numbers. Here's the code: #include "stdafx.h" #include <iostream> #include "time.h" int main() { clock_t t = clock(); long x = 1000000; long sum =...

I have to generate a list of all possible combinations of numbers and letters of length three. The catch is on the first two characters can be letters or numbers, and the third one can only be numeric. For example: AA1, AA2, AA3 .... FC7 ... 001, 002 ... 365)...

I don't seem to understand how Integer.MAX_VALUE and Integer.MIN_VALUE help in finding the min and max value in an array. I understand how this method (pseudocode below) works when finding the min and max values: max = A[0], min = A[0] for each i in A if A[i] > max...

This question already has an answer here: Generating random numbers in Javascript in a specific range? 14 answers For example: Math.floor((Math.random() * 99999) + 10000); Would return numbers from 10000 to 99999. (Please correct me if I am wrong) However I get a numbers like 103783 etc. sometimes.Why is...

I am using the 64-bit verison of the Mersenne Twister, specifically the version: A C-program for MT19937-64 (2004/9/29 version). Coded by Takuji Nishimura and Makoto Matsumoto. and am receiving an integer overflow when compiling into the Release but don't get the exception during run-time in Debug. I have integer overflow...

I was in a programming competition and I needed to calculate the order of a permutation on a million number. Of course the order of a permutation is just the least common multiple of the cycle length. Therefore the problem boils down to this: given some integers that add up...

I have a problem with this function always my mt_rand() give me the same number: $hex = 'f12a218a7dd76fb5924f5deb1ef75a889eba4724e55e6568cf30be634706bd4c'; // i edit this string for each request $hex = hexdec($hex); mt_srand($hex); $hex = sprintf("%04d", mt_rand('0','9999')); $hex is always changed, but the result is always the same 4488. Edit $hex = str_split($hex);...

This question already has an answer here: HTML Text Input allow only Numeric input 43 answers I have a field in JSF2, I tried execute a validation in this way: <h:inputText value="#{manutencaoContratoBean.contrato.nuContrato}" style="text-align: left; width: 90%; "> <f:convertNumber pattern="#######" maxFractionDigits="0" maxIntegerDigits="16"/> And thus: <h:inputText value="#{manutencaoContratoBean.contrato.nuContrato}" style="text-align: left; width: 90%;...

ok I'm very new to R and this is a general question. I have various numbers and I want to replace the whole part and keep the decimal part unchanged. For example I have values from 25.01 to 25.99, I want to replace 25 with 10 but keep the decimal...

How do you do a range of numbers in livecode? I tried using "-" like this if the loc of the image "yellowdisck.png" is 0 50,0-640 then But this doesn't work....

I would like to sort an array of objects by a property of the specific object. This is my array with objects: As you can see I have an array $all_studies with 2 objects. How can I now sort on the graduationYear property of the objects? So I would like...

I did some research, but didn't found any solution for my question. What I want to archive: Generate a random number out of 0's ($min) and 1's ($max), but with a fixed amount ($many) of 1's in the random number. The random number should have a length of 6 as...

I have problem using automatically generated Tex string in arguments where a numeric value are required (e.g. in ifthenelse comparison). Here is a sample minimal code : \newcommand\testC{123} \ifthenelse{\testC<0}{negative}{positive} % works fine ! \newcommand{\testD}{\luaexec{tex.write("123")}} % write to avoid the print carriage return - produces also 123 as \testC \testD %...

The thing that I have to do is to extract every 'single' number, that doesn't has another number right before or after itself. Then I have to replace this number with an number, that is incremented with 1. I now want to a Regex that gets every single number from...

I have a random number generator function that returns a random number. It looks like the problem is that sometimes it returns only one decimal place the, tenths place(i think it's called). I always want it to output a number with 2 decimal places (some times i would get 10.5...

I'm writing a function for a program and I need to generate a list of numbers in an Object[] For example. Object[] possibilities = functionName(13); Should generate Object[] possibilities = {"1", "2", "3","4","5","6","7","8","9","10","11","12","13"}; How should I go about achieving this?...

1. script: $num = "00445790"; echo $num; returns: 00445790 2. script $num = 00445790; echo $num; returns: 2351 Can somebody explain why I get 2351 on the second script?...

I'm working on a AutoIt script and I have to convert some weird hexadecimal number to normal integer. But I don't know which procedure should I follow to convert my hex number. For example, in the AutoIt documentation below, some definitions and their hex values are given. But they didn't...

I have problem with extracting numbers from string. Problem is I can not use strtol or isdigit functions as teacher requested so. I am supposed to save numbers in new array. For example, string input: 11-some12meh13text-14 . So new array would be: 11,12,13,14 (NOT -14) I came to idea to...

This question already has an answer here: How does Integer.parseInt(string) actually work? 5 answers How does the internally parsing of strings into number formats work? I have imagined something like this. Does that match to the actual implementation? (not related to any particular programming language) int getDigit(char c) {...

I have a number in this format: 3 320,17 And I need to get it like: 3320,17 if I use: floatval($price) it only return the number 3 separated by the space. Any idea how to solve?...

This question already has an answer here: php test if number is odd or even 11 answers How can I get if a number is even or odd or neither (have decimal, like 1.5) with PHP? I know that there are operators like *, /, but they did not...

I am having a small problem with the code below, instead of a number I am getting NaN. What's wrong? for (var i = 0; i<100; i++) { x = i ^ i result = x + result; } var y = result - (result ^ result); console.log(y); ...

I'm working on a project where I have a pane that goes from 0 to 500 on the x and z, but I need to convert that coordinate (from 0 to 500) to a float in the range of 0.0 to 1.0 in because it is required from some of...

I have a task to make a program that will sum the first 100 Fibonacci numbers. I checked my output in Python, and my output in QBasic 64 and they aren't same. I checked with different inputs also. Input: 10 Output: 89 ----------- Input: 100 Output: 573147844013817084101 Is it correct...

When a counter is made up from a fixed number of digits (2 in the title), standard counting-up works by incrementing from the least to the most significant digit and upon overflow reset it. I want to count differently: A 4 digit number in base-10 would be counted up in...

Can someone help me with the following: I have a date, for example: 3-1-2014, And I would like to convert this to the number 5, because it is a friday. So 7-1-2014 would be 1, because it is a monday. Which package/code can do this for me? Thanks...

I have a string which contains a number. It can be one with decimals, followed by either a comma or a dot, depending on the user's locale. The numbers are actually hundredths and I want to convert them to plain old ints. For example, I want strings "14.5" and "14,5000"...

I have the following problem with batch files. I simplify the problem below. Running the following batch file, foo.bat, returns word in standard out (in this case, command prompt window) instead of hey. foo.bat @SET 1word="hey" @ECHO %1word% However, executing echo %1word% from the command line returns hey. Is there...

I want to ask how I can reorder the digits in an Int32 so they result in the biggest possible number. Here is an example which visualizes what I am trying to do: 2927466 -> 9766422 12492771 -> 97742211 I want to perform the ordering of the digits without using...

I need your help. I'd like to create a function that would add some zeros in front of a number. The maximum numbers of digits that the total string should have is 6. Here are examples: 9 -> 000009 14 -> 000014 230 -> 000230 1459 -> 001459 21055 ->...

Given a string: $pages = "1,2,3,4,5,6"; Create a function that gets the numbers on the left and the right of the given element. I expect this ouputs: pagination(1); // array('prev' => null, 'next' => 2); pagination(2); // array('prev' => 1, 'next' => 3); pagination(6); // array('prev' => 5, 'next' =>...

I have a csv file to import to Power Query (250,000 records). One field contains our fee codes which are usually entered as numbers but sometimes contain characters (e.g. 17, 17A, 67, 67A, etc). When I import the file to Power Query, the field is treated as a numeric column...

How do I concatenate a number to string everytime I click on the button? If I log cConcate variable you will see that the first value is right but on subsequent clicks the url refuses to update. var tNumber = 1; var sSting = "http://www.test.com/"; var cConcate = sSting +...

This question already has an answer here: Check if input is float else stop 6 answers So, I'm creating a program that calculates the area of a triangle, and I need it to tell the user if he typed a letter or a negative number, in order, I created...

My code: <af:inputText id="it1" label="Test"> <af:convertNumber groupingUsed="true" type="number" messageDetailConvertNumber="#,###,##" maxFractionDigits="2"/> </af:inputText> When I type 100,51 -- everything is fine, but if I would type 100,50, then '0' will be removed and entered value will be 100,5. How can I leave this '0' in the end? I need <af:convertNumber> element for...

I set out to write a Prime Number Checker: import java.util.Scanner; public class PrimeChecker { int userEntry; int even_check; int odd_check; final void run(String[] args) { Scanner jaiho = new Scanner(System.in); System.out.printf("Please enter a prime number: %n"); userEntry = jaiho.nextInt(); even_check = userEntry % 2; // This is to get...

As noted in the PHP documentation, when json_decodeing a data structure containing long integers, they'll be converted to floats. The workaround is to use JSON_BIGINT_AS_STRING, which preserves them as strings instead. When json_encodeing such values, JSON_NUMERIC_CHECK will encode those numbers back into large integers: $json = '{"foo":283675428357628352}'; $obj = json_decode($json,...

This question already has an answer here: How do I sum numbers using a prompt, like a simple calculator? [duplicate] 1 answer Heyy guys, I am trying to create an calculator that can sum. What I am trying to do is: Search for the plus, and get the place...

I’m doing my first steps on Ocaml and I want to write a function which will receive two numbers in String variables and will return the sum of the two received numbers in an string. I know I could do the following let sum a b = match a,b with...

I'm taking a discrete mathematics course, and I'm required to develop a c++ program which receives a string as an input and returns which natural number (if any) it represents. Natural numbers are defined as follows: 0 = {}, 1 = {{}}, 2 = { {} {{}} }, 3 =...

I'm developing a map and I have to save this parameters on Parse database: lat.: 20.6350 . Long: -103.5334 The problem is when i convert them into numbers, that function converts 20.6350 to 20.635. ¿What can I do in order tu preserve the last zero?...

This is weird. This is what happens at the JavaScript console in Chrome (version 42.0.2311.135, 64-bit). > 0 < 0 > 00 < 0 > 0.0 < 0 > 00.0 X Uncaught > SyntaxError: Unexpected number Firefox 37.0.2 does the same, although its error message is: SyntaxError: missing ; before...

I am trying to find the first common number (FCN) from e.g. 5 individual number lists. For example the 5 number lists are these ones: list_1 = [13579875, 25732, 3541, 56732, 1567, 20546, 10, 68971] list_2 = [1856721, 25724, 3541, 56732, 1567, 20546, 10, 68971] list_3 = [2354074, 25732, 3541,...

I want to extract a number from a text file. First I read the file and import is as a cell array of the form: A = { '1 0 0 0 - 0: 0.000741764' '2 0 0 0 - 0: 100' '3 0 0 0 - 0: 100' '4...

If I randomly put in two numbers (first number is smaller), how do I use a for-loop to add all the numbers between and itself? ex: first number: 3 second number: 5 the computer should give an answer of '12'. How do I do that using a for-loop?...

I'm regularly editing CSS in Vim and need to change a value like: width: 300px; to something else like: width: 178px; Normally what I do is navigate to the 3 in 300 and type cw to change the word. But if I do this I have to type the px...

I created a function that will test to see if a given parameter is a square number. Read about square numbers here: https://en.wikipedia.org/?title=Square_number If the number is a square number, it returns true and otherwise false. Negative numbers also return false. Examples: isSquare(-12) // => false isSquare( 5) // =>...

Maybe I just have a knot in my synapses... public static <T extends Number> T firstNonZero(T... values) { for (T value : values) { if (value.doubleValue() != 0.0) { return value; } } return (T) 0; // Cannot cast from int to T } I guess I don't need to...

$temp_price_1 = round($price * ((100-$sale_percentage) / 100), 2); $price = $temp_price_1; im using this code to subtract a percentage from a number, for this example my starting number for $price is 24.99 and the $sale_percentage is 50.0 this result is the $temp_price_1 being 12.5 which is correct, however i need...

Does anybody know if there is a way of removing (trimming) the last two digits or first two digits from a number. I have the number 4131 and I want to separate that into 41 and 31, but after searching the internet, I've only managed to find how to remove...

This question already has an answer here: What's the best way to get the fractional part of a float in PHP? 6 answers How to get whole and decimal part of a number? 6 answers I have variable which is a float number $num = 10.5; and I want...

I need to parse a table of numbers formatted as ascii text. There are 36 space delimited signed integers per line of text and about 3000 lines in the file. The input file is generated by me in Matlab so I could modify the format. On the other hand, I...

I have an integer input like this 1213121 I would like to count how many palindromic sequences are there (the ouput must be 5 palindromic sequences) Because the first palindromic sequence is 121. The second is 1213121. The third is 21312. The fourth is 131. The fifth is 121. I...

I have a directory with these files: 1.html 22.html 333.html zxc.html I want to get a list of the html files that only have digits in their name: 1.html 22.html 333.html I thought this would work find . -regex '^[0-9]+\.html' or ls -al | grep -E '^[0-9]+\.html$' But I get...

So I'm trying to find a prime number, and store it in an array. The ones I looked at and searched are somewhat confusing and my teacher's explanation is confusing in it self. His pseudo code is confusing and my current code that I have is prime = [False,False] anumber...

How do I square a number's digits? e.g.: square(21){}; should result in 41 instead of 441...

I am trying to generate the next available ad account using incremental numbers. for example, my domain currently has accounts names"opr1000-opr1014", so when i run my script, i should expect opr1015, instead it gets stuck in a loop and never returns a value. I have it running a do while...

I am generating a random number in my game using: System.Random rnd = new System.Random (); int TileType = rnd.Next (0, 8); The problem is that the numbers are too random. The numbers relate to tiles and i didn't get a particular tile for 20 rolls. I need guidance on...

I'm trying to increase by one this number: 9223372036854775808: var number = 9223372036854775808; var plusOne = number + 1; This should yield 9223372036854775809, but it instead yields 9223372036854776000. Why? More important, how can I fix this?...

In Perl code, you can put underscores in large numbers to improve legibility. For example, the number 123456789 is equivalent to 123_456_789, which helps the coder understand what number it represents. Is there a character in PHP that I can use for the same purpose? I have tried commas and...

I need a function to check if number have 2 decimals or not. For example: $number = '1.00'; // Valid $number2 = '1'; // Not valid $number3 = '1.000' //Not valid ...

This question already has an answer here: Why is the order in Python dictionaries and sets arbitrary? 5 answers I have a question about dictionary properties in python when the keys are number. in my case when I print a dictionary with number keys the result of print will...

I'm trying to calculate a function that will return the average for an number of integer arguments. Who can help? var Calculator = { average: function(x) { var num = 0; for (var i = 1; i <= x.length; i++) num = num + x[i]; var divide = num/x.length; return...

$result = reduce($number); function reduce($number) { $new_number = 0; if($number < 10) { return $number; } $q = floor($number / 10 ); $r = $number % 10; $new_number = $q + $r; if($new_number <= 9) { return $new_number; } else { reduce($new_number); } } I want to sum the numbers...

I have a table field where the data contains our memberID numbers followed by character or character + number strings For example: My Data 1234567Z1 2345T10 222222T10Z1 111 111A Should Become 123456 12345 222222 111 111 I want to get just the member number (as shown in Should Become above)....

I'm stuck with a column in varchar(50) here that I would like to have in currency format. Some examples of the AMOUNT column are: -128,533.74 -55,156.11 77,120.24 I just keep getting an error saying can't convert. What's the best way to handle this with the punctuation and sign?...

I've got the following pen: http://codepen.io/anon/pen/LVLzvR I cant quite figure out how to round the number up so you don't break the punctuation. I need to round the number up as I don't want to see a value like 33,333.,333 //ADDS PUNCTUATION EVERY THREE CHARACTERS $('input.numericpunctuation').keyup(function(event){ var oNum= $(this).val(); //...

Most Python errors produce traceback showing the line number of the offending statement. But for some reason some run-time errors do not. For instance, running "python -m mymodule.py" on a module containing just the two lines: args = {} if len(args > 2): print("this is a run-time error. Should be:...

How to restrict the input field to enter only numbers/digits int and float both. Sometimes we need to allow both integer as well as float value for fields like amount, so in that case the validation is required. There are no of solutions available but they are of large size...

I've been coding in python for awhile, and I happened to stumble upon Codecademys exercises and one of the projects was to create a battleship game that randomely places a 2x1 battle ship in a 5x5 grid. I noticed a pattern after my girlfriend correctly guess where the ship was...

I'm using JXA for automating a process using Numbers app. What I need is to select a range of cells to apply width, but JXA doesn't allow me to get them. According to apple documentation I only need to use make or push the created object inside of array, but...

I created a database table: I run this query INSERT INTO dbo.Stats (Date_of_Record, Rack_Code, Total_MB, Schools_MB, Percent_Schools, Central_MB, Percent_Central) VALUES (CAST(GETDATE() AS DATE), '78Q425', 45, 297, 1, 361, 0, 12, 0) and I get an error Msg 110, Level 15, State 1, Line 1 There are fewer columns in the...

I am using the number format plugin for jQuery, specifically jQuery Number Format: Redux, and for some reason negative numbers are reformatted as positive. If I have <span format='float'>-50</span> and call $('span[format="float"]').number(true, 2); The negative is removed and returns 50.00 instead of -50.00 see this JSFiddle example...

I have a form with a text box which accepts 12 Numbers as input. I want to be able to search for 2 digit, 3 digit, 4 digit and 5 digit combinations and show predefined outputs for each such combination found. Example Text entered in textbox : 919982115672 Outputs 8211...

I'm working on a status bar application. Currently all I have is a drop down menu that either quits the app or opens a preferences window. There is a textfield in the window that will be for a number value. While testing I noticed that when I used .orderOut to...

I am trying to write a function in JS that returns a number's maximum "prime" factor. For example, if I ran maxPrimeFactor(57), I should return a 19. However, my function only works part of the time. I have written a helper function called isPrime that returns a boolean that indicates...

So what I would like is a very simple edit text with input type number or decimal that has the following aspects. Number Edit Text: You can only type up to Long.MAX_VALUE / Long.MIN_VALUE, so I can cast to a long without modifying the user's input. Number Decimal Edit Text:...

I'm studying Javascript and I was solving a problem that involves a mathematical computation with floating numbers. I kind of heard that Javascript is weird in treating floating numbers but I was surprised when I saw its impact was this dynamic. How should I have done to get the right...

I'm trying to generate random arrays to test my homework assignments. The Problem is that the numbers generated are always unique , and I need some repeating numbers from time to time. Here is the code I came up with: static int[] RandomIntArray() { Random rnd = new Random(); Console.Write("Enter...

I do not understand the logic behind this number checker and I'm wondering if somebody could help me understand it a little bit better. Here's the code: I will do my best to comment on what's happening but I do not fully understand it. //find prime numbers between 2 and...

For example: 410589 actually shows up as 410K 4509 actually shows up as 4K 349 actually shows up as 349 I'm looking for a way to shorten very large numbers into a nice to read format....

I have just observed that the parseInt function doesn't take care about the decimals in case of integers (numbers containing the e character). Let's take an example: -3.67394039744206e-15 > parseInt(-3.67394039744206e-15) -3 > -3.67394039744206e-15.toFixed(19) -3.6739e-15 > -3.67394039744206e-15.toFixed(2) -0 > Math.round(-3.67394039744206e-15) 0 I expected that the parseInt will also return 0. What's...

I'm writing a script and I'm kinda stuck at the following part: Inside a case statement, I want to check whether or not the "--sn" command is followed by a number (1-254). I thought i'd just use --sn*, but apperently * doesn't work for numbers? case "$1" in --sn* )...

When I use this : preg_match('/^[0-9]{1,10}(\.[0-9]{1,9})?$/', 0.0001); The return value is 1, and when I use this : preg_match('/^[0-9]{1,10}(\.[0-9]{1,9})?$/', 0.00001); The return value is 0. Somebody could say me why please ? Thanks !...

Let's say I have a string of numbers separated by spaces and I want to return the highest and lowest number. How could that best be done in JS using a function? Example: highestAndLowest("1 2 3 4 5"); // return "5 1" I would like the both numbers to be...