Click here to Skip to main content
15,891,708 members
Everything / Numbers

Numbers

numbers

Great Reads

by Christ Kennedy
A graphically bouncy and colorful version of the popular numbers tile-sliding game
by ZackAkil
Explanation and demo of using prime factors to index text records
by User 6679439
Library extending the .NET numeric support
by NightWizzard
Convert amounts to their spoken equivalents

Latest Articles

by Pete O'Hanlon
How to use arrays to manage multiple items
by Pete O'Hanlon
Getting started with TypeScript
by Christ Kennedy
A graphically bouncy and colorful version of the popular numbers tile-sliding game
by DataBytzAI
Part one of a series to demystify and democratize the magic (not) of AI

All Articles

Sort by Score

Numbers 

6 Oct 2020 by Christ Kennedy
A graphically bouncy and colorful version of the popular numbers tile-sliding game
19 Jan 2017 by ZackAkil
Explanation and demo of using prime factors to index text records
2 Dec 2017 by User 6679439
Library extending the .NET numeric support
18 Dec 2016 by NightWizzard
Convert amounts to their spoken equivalents
1 Jun 2018 by umar.techBOY
The two functions convert/parse number strings with prefix multipliers (Milli, Kilo, Mega, Giga, etc). The code includes try/catch blocks for tolerating writing styles.
6 Jul 2012 by OriginalGriff
I would change it slightly, by putting a check digit either at the start or end of the number:If you use a (sum-of-digits plus digit-position-number) modulo 10 then your are unlikely to get the same check digit by a simple mistake. This would also protect against transposed digits: 12435...
4 Aug 2014 by Thanks7872
See this :int month = DateTime.ParseExact("Aug 2014", "MMM yyyy", CultureInfo.InvariantCulture).Month;//month will be 8 in this caseAdd reference to System.GlobalizationRegards..
20 Sep 2013 by OriginalGriff
The term you are looking for is not "byte-form", it's "binary" or possibly "binary string".Converting it is pretty easy: int i = 10;Console.WriteLine(Convert.ToString(i, 2).PadLeft(8, '0'));But you don't need to convert it to check bits: int i = 10; for (int j = 7; j >= 0;...
12 Jan 2014 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.And if you find that to have...
12 Jan 2014 by CPallini
Man, that algorithm is really simple: for the given input n it searches, starting from (n-1) downwards for a prime number (this is the outer loop). For every prime-number-candidate it uses the prime number definition for testing primality: repeadly attempts to find an exact divisor (that would...
8 Apr 2014 by Peter Leow
1. First, split the whole string into array of number strings using non-digit as delimiters.2. Next, count the array for repeated number strings and store them as key value pairs in a Map3. Do whatever you like with the MapSee example:String str = "71 geese - 83 cars - 58 cows- 64...
9 Mar 2016 by OriginalGriff
So stop converting it to a number and start by validating the string.Create a bool value "hasPoint", and set it to false.loop through the input string, examining each character in turn.If it is a '0' or a '1', then it's fine.if it's a '.', then check "hasPoint" if it's false, then set it...
14 Jul 2016 by OriginalGriff
You can't change RAND_MAX because it's a constant, and its implementation dependant: it can be set to the maximum value that can be stored in a signed integer on the system the compiler is targeting (but it doesn't have to be, it can be smaller): on Windows based systems it is set to 32767 for...
6 Aug 2016 by Patrice T
Quote:How can I improve my counting prime numbers function?there is nothing to improve, because what you have done is not working.the whole logic of your code is to be reviewed.Your logic actually say that i is a prime if not a divisor of n, it is plain wrong.You need to create a function...
26 Mar 2017 by OriginalGriff
Put a breakpoint on the "if" line.Run your app in the debugger.Click on the TextBox.Press '-'.Look at the content of ch
4 Dec 2018 by Richard MacCutchan
Start by avoiding compound statements like that, where you cannot see the results at each step. Use String.Split to get an array containing the four fields, then convert each one to its integer value. From that you can use the String.Format Method (System) | Microsoft Docs[^] to display them as...
10 Feb 2020 by Patrice T
Quote: Coordinates to grid box number This is not a programming problem, it is a mathematics problem. You need to figure out the solution, and you don't need a computer for this, even if it can help. All you need is a sheet of paper, a pencil...
8 Feb 2020 by User 11060979
As @ppolymorphe mentioned it is not a big problem to calculate it. Given is: Field width: W Field height: H Columns: C Actual coordinates: X, Y With this you can easely calculate column and row with something like this: columnXY= ConvertToInteger(X / W) rowXY= ConvertToInteger(Y / H) Finally...
20 Jan 2022 by M Imran Ansari
Try the following link: Python program to print the binary value of the numbers from 1 to N - GeeksforGeeks[^]
25 Feb 2023 by Pete O'Hanlon
How to use arrays to manage multiple items
6 Jul 2012 by Stephen Hewison
Hi,Soon I may be required to serialise many thousands of devices labelling them with an integer number.The purpose of the number is to allow the device to be activated by entering the number assigned to it via an interface on a mobile phone. The process relates to real money...
14 Oct 2012 by vivektiwari97701
http://weblogs.asp.net/salimfayad/pages/arabic-textbox-control.aspx[^]
13 Nov 2014 by nv3
Your problem seems to be that you don't have the integer-based multiplication and division implemented correctly. Let's start with multiplication:You said, you scale both operands by multiplying with 2^14. Then you have to scale the result by dividing through 2^28. For example:double a...
29 Nov 2014 by OriginalGriff
Look at your for loop: it's what does the work.At the moment you do this: for (i = 0; i
2 Dec 2014 by OriginalGriff
Checking is always worth it: it saves a heck of a lot of grief later on!The code isn't bad at all - it could possibly use disposal of the multiple-array-access code, but the compiler will likely optimise that anyway.You could try for (i = 0; i
15 Jan 2015 by Sergey Alexandrovich Kryukov
Force? Wrong word, I would say. You just need to output what you want.The problem you have is: all (is I'm not much mistaken) Arabic cultures and Urdu cultures use… "Arabic numerals" ("Indo-Arabic"), which are ironically… Western European 1234567890.What you show is not...
7 Apr 2015 by Sergey Alexandrovich Kryukov
So far, I came up with only some trivial solution: use one more intermediate int object. This is not prohibited by the problems formulation. You can use it to represent a kind of "array of digits". You have only 10 digit, so a digit object needs only 4 bits (half-byte) to represent. But maximum,...
11 Apr 2015 by User 59241
This will do it. It will handle multiple occurrences of digits but not 0 of course (at present 0 is ignored). If required 0 would have to be placed after 9. Easy enough to do. #include int main () { const __int64 input = 456120; __int64 output = 0, temp1; int len =...
9 Mar 2016 by Jochen Arndt
The simplest solution would be checking the string (the characters) when the number is entered (as stated in the question):bool bResult = (*input != 0);int decPoint = 0;while (bResult && *input){ switch (*input) { case '.' : decPoint++; case '0' : case '1' :...
9 Mar 2016 by Jochen Arndt
The behaviour is defined by the standard (see fprintf[^]):Quote:The exponent shall always contain at least two digits. If the value is zero, the exponent shall be zero. So the only solution would be printing to a buffer using sprintf() and modifying the string afterwards.Example:char...
10 Apr 2016 by Patrice T
Quote:i need helpho can i add two numbers using function in visual basicWhat you need is to learn the language and this, we can't do it for you.I recommend to read VB documentation and follow tutorials. You will find the answer to your question pretty soon.The question tells us that...
6 Aug 2016 by Patrice T
You should learn to use the debugger as soon as possible. Rather than guessing what your code is doing, It is time to see your code executing and ensuring that it does what you expect.The debugger allow you to follow the execution line by line, inspect variables and you will see that there...
26 Mar 2017 by Dave Kreskowiak
Creating a numeric only TextBox isn't that simple.Do you have code in place to handle copying and pasting from the textbox? Probably not.Sure, you're limiting key presses, but how about pasting in a non-numeric value?How about the arrow keys?Delete and Backspace?By the way,...
24 Oct 2017 by OriginalGriff
Replacing the comma with a dot won't work: that doesn't create an integer - it creates a a floating point number: "0.1234" which will not parse as an integer. You could use double.TryParse instead of Convert.ToInt32 and then cast that to an integer, but that will just give you zero, as the...
25 Nov 2018 by OriginalGriff
Try: string Mystr = "2_4ad-6kss-2_5kk-3_40ppp"; string[] numbers = Regex.Split(Mystr, @"[^\d_]+");
1 Sep 2019 by Patrice T
Quote: I'm getting terminated due to timeout error. I can't view the test cases too. So,I really have to idea why it's happening. The error message means that the program takes too much time to complete the tests. You need to make your program faster. Memoization can do the trick: Memoization -...
19 Feb 2020 by OriginalGriff
To be honest, I wouldn't use a Regex - I'd use TryParse: NumberStyles styles = NumberStyles.Integer | NmberStyles.AllowCurrencySymbol; CultureInfo provider = new CultureInfo("en-US"); if (int.TryParse(stringToConvert, styles, provider, out...
18 Aug 2021 by Richard Deeming
Generate a random number between 65280 (0x00ff00) and 16711680 (0xff0000). Math.random() - JavaScript | MDN[^] function getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min) +...
20 Oct 2021 by CPallini
You know, you cannot random pick the numbers in their allowed ranges. For instance, you cannot choose a=0, because then no pair of {b,c} values could fullfill the requirement a + b + c = 85 You can however, freely random pick a in the [25,40]...
19 Feb 2022 by Richard MacCutchan
You should not use string().split(), as that assumes that all numbers are complete substrings. The firs string after the split will be "Hi5" which does not begin with a digit. You should check all characters on by one, accumulating digits. As...
26 Sep 2022 by CPallini
Thisputs "how many items?" items = gets.to_i arr = Array.new(items,10) for i in 0..items-1 puts "please enter item #{i}" arr[i] = gets.to_i end should fix your code. Now it is up to you actually fulfilling the requirements.
30 Jan 2012 by speshulk926
I have an existing system that is in XML Format that I am trying to parse and import into SQL. I'm having an issue with a particular field for dates. I was hoping someone could look at this and figure out what these numbers mean, because I have tried a lot of different things and can't figure...
30 Jan 2012 by Sergey Alexandrovich Kryukov
Basically, assuming that on input you are given the correct number of 100-ns tick counted from January 1, 0001 at 00:00:00.000 in the Gregorian calendar, you can construct the instance of System.DateTime using this constructor:http://msdn.microsoft.com/en-us/library/z2xf7zzk.aspx[^].If...
12 Jul 2012 by MR. AngelMendez
Hi, I have a string with a sentence. The string is displayed in a richtextbox. The user types a letter in a textbox and the program attempts to find that letter in the string. I want to make it that when the user presses a button a messagebox appears and displays the letter along with its...
12 Jul 2012 by willempipi
Make a handler to the KeyPress event of the textbox. Then check out 'e.KeyChar'.
14 Oct 2012 by progahmed
Helloi have an asp.net webpage with multiple textboxes how to force write arabic numbers in textbox at run time instead of English numbers 123 ??help me pleasethank you
5 Nov 2012 by bEGI23
How long can a Service Tag be, is it even specified?
15 Nov 2012 by kurtiniadiss
Hi all,I want to use to_number() function as it works for ',' seperated or '.' seperated floating numbers. I searched some links but I could not find any useful code part.Do you have any sample usage as I told?Thanks in advance
18 Dec 2012 by robert_54
I have a datagridview in one form which has a quantity field. it contains int type of numbers. I want to be able to create a combobox field in another datagridview in another form which will get a range depending on the quantity in the other form.for example the quantity I input in the first...
18 Dec 2012 by Jibesh
You could try setting different data source to the cell than for the grid.like this:DataGridViewComboBoxColumn newColumn = new DataGridViewComboBoxColumn();newColumn.Name = "abc";newColumn.DataSource = new string[] { "a", "b", "c" };dataGridView1.Columns.Add(newColumn);foreach...
17 Jan 2013 by F.moghaddampoor
Well you should define a margin, like say the diffence between numbers.So lets say the margin is 2.write a for loop:int[] a=new int[100]for (int i=0;imargin...
6 Aug 2013 by mbue
At the beginning i==0 therefore the value of check in the first do{}while loop is always false. The function runs in an infinite loop.to avoid this take a look: for(i=0;i
6 Aug 2013 by Sergey Alexandrovich Kryukov
Never ever use loop variable declared outside of the loop!—SA
6 Aug 2013 by Sergey Alexandrovich Kryukov
Never ever use loop variable declared outside of the loop!—SA
29 Sep 2013 by IAmABadCoder
I'm trying to make a program where i can write in a certain number to trigger multiple functions.But I'm having trouble identifying when a certain number is used. For an example say i have the number "10" i would like to change it to a binary string(00001010) automatically using an algorithm...
11 Oct 2013 by ASP.NET Community
The RegularExpressionValidator control confirms that the entry matches a pattern defined by a regular expression. This type of validation allows you
24 Feb 2014 by Member 10308221
i want to have a combobox in ribbonbar that allows only digits to be entered in its edit box.no character should be allowed to be entered.programming language :: Visual C++some one help me please.
22 Apr 2014 by Abhinav S
A similar question was answered at Count number of words in text file[^].
11 May 2014 by DamithSL
You can use single line to check int value for even or odd public static bool IsEven(int num){ return num%2 == 0;}public static bool IsOdd(int num){ return num%2 != 0;}
13 Jun 2014 by jump_ace
I'm trying to build a Powerball randomizer and I'm nearly finished. I need help with getting the first 5 numbers to no repeat themselves (the 6th, PowerBall number can repeat). I'm not sure how to tackle it as I'm still pretty new to writing code. Any suggestions and tips on how to do it...
13 Jun 2014 by norbitrial
I have some suggestions for you, I hope I can help you with this!1. First of all I suggest always use semicolon after your line of code.2. You don't need to push one by one values into an array, you can do that with for or while cycle as follow:var NoOne = new Array();for (var...
16 Jun 2014 by Matt T Heffron
You don't want to use different arrays for the first 5 numbers. Use the same array so you can track which numbers have been selected already:// EDITED: MTH -- moved to below//var FirstFive = new Array();// for (var i=1; i
16 Jun 2014 by jump_ace
I found a workaround all on my own *gasp!* :)I just added a reload command at the end of the function so it reloads the page every time you click the Generate button. Here's my final code for one set of numbers. Thanks for your help guys!var FirstFive...
25 Jun 2014 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.Try it yourself, you may find it...
26 Jun 2014 by Narendra Singh
I am developing a cyber cafe web application where admin want to get details of number of print out taken from every system . please help me how is it possible. Please help me.
26 Jun 2014 by DamithSL
it depend on how users took printouts. for example if user get print screen and past it on mspaint and took printout from that, you can't get print information of such case from ASP.NET.But if you have print button on your asp.net web page and you can save record to database with print details...
4 Aug 2014 by kk2014
Hi,I need month number from string text.ex: from "Aug 2014" , I should get 8, if "Jul 2014" then 7.thanks,
4 Aug 2014 by Snehasish_Nandy
Refer below linkhow-to-display-month-number-on-selecting-month-name[^]Hope it will help..
13 Nov 2014 by Jinoj S
Hello,I'm working on writing a C program to perform division of 2 complex numbers in Fixed Point.I'm not able to get the fractional part from it. Below is more details on it.I have 2 complex numbers:N = a + ibM = c + jdI need to do N/M in fixed point (not using floating...
22 Nov 2014 by GeorgeGkas
Giving an array with size of N the C program will read a text file that contain numbers separeted by whitespace and will store them into the array. The N number is the first one in the file and is in different line than the other numbers. Example of txt file:109 8 5 4 585 2 14 5 9 8...
29 Nov 2014 by GeorgeGkas
I found thatc code on the internet tha generate as many numbers as we want, increaced bu 1.So if we want to generate 10 number it would generate 10 numbers plus one for the header.Example.100 1 2 3 4 5 6 7 8 9But can I change the code to start generate the number backwards and...
29 Nov 2014 by Richard MacCutchan
This is all you need: int count_to_generate = 1000000; // This the number of numbers you want int i; FILE* fp; // Append header and line break fp = fopen("test.txt", "w"); fprintf(fp, "%d\n", count_to_generate); for (i = 0; i
12 Mar 2015 by Member 10500506
Hello Everyone,I need one solution to prevent automatic rounding of number in oracle. Here I am explaining what I want.Please go through this flow.SQL> create table dm_demo(no number(23,9));Table createdSQL> insert into dm_demo values (9999999.999999999);1 row...
14 Mar 2015 by Jörgen Andersson
As Tom Kyte says[^]: "SQLPlus has a default number format is uses to display data on the screen "nicely". You need toeithero set the numformat to something you likeo use a TO_CHAR on the number with a format that applies in your case.Info on how to set Numformat here[^].
17 Mar 2015 by Smart003
in oracle to display a numbers after the decimal point we use the concept of precision in the number datatype.check about it
26 Mar 2015 by Parazival
thankx............................................................
7 Apr 2015 by OriginalGriff
This is your homework, so we won't give you code.But... I can understand you not knowing quite where to go here.So a couple of hints:1) Have you ever heard of Binary Coded Decimal? Look it up...2) You can extracted individual hex digits (or groups of for bits) with AND, OR, and NOT...
11 Apr 2015 by Sugar Richard
A little bit fuzzy on the exact spec. Hope this helps.uint32_t merge_digit(uint32_t hi, uint32_t lo, uint32_t base){ uint32_t r = 0; uint32_t m = 1; while ( lo != 0 && hi != 0 ) { uint32_t p1 = lo % base * m; uint32_t p2 = hi % base * m; m *= base; if (p1
3 Jun 2015 by Vithya Rasalingam
I'm creating a country code finder i have a masked text box to enter the phone numbers and want to extract the code number from it and find the country belongs to that code number oi need your help to extract the code and find the code from my database
3 Jun 2015 by Sujith Karivelil
Let mskTexte your maskedTextBox and (99) 000-0000 be your mask for mobile number. then you can extract the country code by using the following code Dim countryCode As String = mskText.Text.Substring(1, 2)
25 Aug 2015 by Sergey Alexandrovich Kryukov
All bachelors in Computer Science should be able to solve such a trivial problem if first year of their education. But you don't even understand that there are no "binary" and "hexadecimal" numbers. You really deserve taking your diploma away. Would would like to work with you, with your skills?...
5 Sep 2015 by Member 2007625
It took few days for me to find this solution and I think it worth sharing it.
7 Oct 2015 by brixharry
In my project I use the MonthCalendar-Control in vb.net. I use the .showWeekNumber property of the control.I now noticed that there is an error in the week numbers in year 2016. Each week number is 1 number too high: When I look at the MonthCalender-Control and view December 2015 and also...
8 Oct 2015 by phil.o
It may be your result that is wrong. Are you sure you are computing this number as per ISO 8601 week date[^]?
12 Oct 2015 by brixharry
Seems a bit like this. Bu have a look at outlook 2010. There you can set how to calculate the first week of a year in the settings of outlook-calendar-options. Options for first week are: - week containing Jannuary 1st - first full week - first week with 4 days of the new year (this is...
22 Nov 2015 by CPallini
The modulus operator (%) is your friend. You know, for instance: int i = 645; int a = i % 100; // a is 45 int b = i - a; // b is 600
16 Dec 2015 by zakpucci2
Hey. Stumped over here.I have a JSON string returning data from a payment API, it is implemented into my html code via PHP:The issue is that the API pulls in number values only with no decimal conversion on the API end. My system is converting the number to a decimal which is one decimal...
9 Mar 2016 by Rupam Bhaduri Pro
float num = 10.0111printf("%E",num);Output: 1.001110E+001But I want = 1.00111E+1What I have tried:I read many website there were written that no hands on solution is available in C library.
14 Jul 2016 by Aamir Yousafi
Dear all, I have been through the forums and Google and have found only complicated setups for random number generators that are more advanced than rand(). My problem with rand() is that I can't seem to change the RAND_MAX, and even when I do by using #undef and #define followed by the integer...
14 Jul 2016 by CPallini
If you can use C++ then have a look at this page: random - C++ Reference[^].
2 Aug 2016 by OriginalGriff
The number 128 is in our "natural" base: base 10.Which basically means that it is really:1 * 10^2 + 2 * 10^1 + 8 *10^0Or1 * 100 + 2 * 10 + 8 * 1Because that is what "base 10" means - you have ten distinct digits (0 to 9) and you get "bigger numbers" you multiply by the base value.But...
6 Aug 2016 by EpicKai
public class Solution { public int countPrimes(int n) { if(n == 0){ return 0; } int count = 0; for(int i = 2; i
6 Aug 2016 by EpicKai
I can't seem to figure out exactly how to count the amount of prime numbers after a certain number.What I have tried:public class Solution { public int countPrimes(int n) { if(n
27 Dec 2016 by OriginalGriff
If you don't know how to do something, Google for it: caller id c - Google Search[^] - as you can see, you are not the first to try this.Look at the TAPI: Telephony Application Programming Interface - Wikipedia[^]
24 Feb 2017 by Member 11543226
I solved this type of error previously but this time am getting stucked.I have a file containing 2,31,200 numbers of 8 and 10 digits and i have to do sum all digits in each number then adding sum into a list, but while adding sums i got error. sum range is 0 to 90. I tried 'int, Int32, Int64'...
24 Feb 2017 by Bryian Tan
Sound like a data issue, these work around will stop the error but it might pollute the results. You need to find out what when wrong in Allbarcodes[i]1. Use TryParse, if failed substitute with 0long sumOfnum = 0;Int64.TryParse(Allbarcodes[i], out...
26 Mar 2017 by Member 13068046
Hi there,I have been trying to find out which number I need to use in order for my text box to allow a negative value input. I've tried all the suggested ones I can find; 189, 109 and Key.Subtract, but none of these are working for me.Below is the code in which I am trying to put...
3 Apr 2017 by OriginalGriff
The trouble is that "2.050.000" is not a number as far as C# is concerned. Although '.' is allowed as a "thousands separator" in several languages, C# does not use them at all, and insists that a number is written as "nnnnnn.dddd" where "nnnnnn" is the integer part, and "dddd" is the...
23 Apr 2017 by Afzaal Ahmad Zeeshan
Complexity of an algorithm means how the time and data or input are related, on a graph. Does the algorithm take more time as the data increases, or does it stay same, etc? There is a notation, Big O notation (e.g. O(n)) that is used to demonstrate this. For your algorithm, I would recommend...