The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
26 views

Representing the hierarchy of groups of numbers using type inheritance

I've run into an interesting conundrum while coding my own implementations for the basic sets of mathematical numbers (Natural, Integer, Rational, Irrational, Real, Complex). I'm doing this mostly for ...
1
vote
3answers
161 views

When is a number a magic number?

Over the last couple of months I have been diving into coding standard IfSQ. As a part of this IfSQ standard, a rule is to not use Magic Numbers. While I don't have a problem with building this rule ...
0
votes
1answer
92 views

Why are floats called “real numbers” in some languages?

Some programing languages, notably Pascal, have a type of numbers called "real". However, mathematically speaking, these types aren't real. For them to be "real", these types have to be able to ...
3
votes
2answers
65 views

Trivially Sortable Encoding for Arbitrary-Precision Decimals

I'm looking for a reasonably(*) space-efficient way to encode arbitrary-precision decimals (e.g. BigDecimal), such that when sorting the bit-pattern of the encodings lexicographically, the numbers ...
0
votes
4answers
336 views

Why is it an issue that it takes 2 digits to represent the number 10 in decimal? [closed]

So we use hexadecimal which has the advantage of going up to 15 in single digits A-F, but why is it an issue that it takes 2 digits to represent the number 10 in decimal? I was reading up about ...
39
votes
3answers
4k views

Are there numbers that are not representable in base 10 but can be represented in base 2?

C# has the decimal type which is used for numbers that needs exact representation in base 10. For instance, 0.1 cannot be represented in base 2 (e.g. float and double) and will always be an ...
0
votes
1answer
102 views

Algorithm for base-conversion in C?

I put in this code which does what it's supposed to do, but perhaps there is a better or more general approach? I'm converting a 4-digit base 10 number e.g. "11" to base 16 e.g. "17" (which gets ...
14
votes
4answers
539 views

How to identify unstable floating point computations?

In numerics, it is very important to be able to identify unstable schemes and to improve their stability. How to identify unstable floating point computations? I am working on a very complex ...
0
votes
1answer
243 views

How many ALU additions are needed to add three numbers?

Please give reasons for your answer. As I found, two additions are needed. This is because every number to be add needs to changed to binary. Then addition is done between two binary numbers where ...
36
votes
1answer
2k views

Where does paypal's 92233720368547800 number come from?

There has been a story in the news about a man whose Paypal account was accidentally credited with $92,233,720,368,547,800. Where does this number come from? What sort of programming bug is likely to ...
0
votes
1answer
383 views

Sum of divisors of numbers of the range ~ 10^6

I was trying to find the sum of divisors of numbers upto 106. The test cases are like of the order of 105. I have done some pre processing like int divisors(int num) { int sum=0; for(int ...
8
votes
7answers
2k views

Why are there so many numeric types (bit, int, float, double, long)?

I've learned PHP, Java, and C. Now I'm curious as to why there are so many types of numerical data types like bit, int, float, double, and long. Why not make only one type for numericals? Is there ...
2
votes
1answer
1k views

What is the time complexity of the algorithm to check if a number is prime?

What is the time complexity of the algorithm to check if a number is prime? This is the algorithm : bool isPrime(int number){ if(number < 2) return false; if(number == 2) return true; if(number ...
0
votes
2answers
229 views

Algorithm for picking reasonable min/max vals given a single value

I am making a simplistic in-browser IDE for some very domain-specific coding. Because I like Bret Victor's thoughts on Learnable Programming so much I thought I'd throw in some draggable numbers ala ...
10
votes
3answers
384 views

Why is the minimum value of ints, doubles, etc 1 farther from zero than the positive value?

I know it has something to do with 2's complement and adding 1, but I don't really get how you can encode one more number with the same amount of bits when it comes to negative numbers.
3
votes
3answers
7k views

Is there something special about the number 65535?

2¹⁶-1 & 2⁵ = 2⁵ (or? obviously ?) A developer asked me today what is bitwise 65535 & 32 i.e. 2¹⁶-1 & 2⁵ = ? I thought at first spontaneously 32 but it seemed to easy whereupon I thought ...
2
votes
1answer
278 views

Filling array with numbers from given range so that sum of adjacent numbers is square number

Problem: Fill all the cells using distinct numbers from <1,25> set, so that sum of two adjacent cells is a square number. (source: http://grymat.im.pwr.wroc.pl/etap1/zad1etp1213.pdf; numbers 20 ...
2
votes
2answers
221 views

Which numeral systems are useful in computer science?

I am wondering which numeral system different programmers are using, or would use if their language has support for them. As an example, in C++ we can use: Octal by prefixing with 0 (e.g. 0377) ...
20
votes
6answers
4k views

Why don't computers store decimal numbers as a second whole number?

Computers have trouble storing fractional numbers where the denominator is something other than a solution to 2^x. This is because the first digit after the decimal is worth 1/2, the second 1/4 (or ...
16
votes
2answers
1k views

Has Little Endian won?

When teaching recently about the Big vs. Little Endian battle, a student asked whether it had been settled, and I realized I didn't know. Looking at the Wikipedia article, it seems that the most ...
2
votes
3answers
1k views

Understanding binary numbers in terms of real world objects

When I represent a number in the decimal system, I have an intuitive knowledge of what it amounts to. For example take the number '10': I understand that it means 10 apples or 10 people... i.e I can ...
2
votes
2answers
3k views

binary representation in Python and keeping leading zeros

I wanted to use the base64 Python library to encode a sequence of binary digits into base 64. Would it be possible to do it without converting to a string? If not, what is the best way to do it, ...
2
votes
3answers
2k views

In programming light, what is special about the number 1223? [closed]

Just came across this post on reddit, where someone was charged $1,223 for a "FREE STEAK SALAD". I was trying to figure out 'Why 1223?' thinking that this might be a programming error somewhere. ...
12
votes
8answers
2k views

Find a “hole” in a list of numbers

What is the fastest way to find the first (smallest) integer that doesn't exist in a given list of unsorted integers (and that is greater than the list's smallest value)? My primitive approach is ...
14
votes
4answers
2k views

How can I properly compare double values for equality in a unit test?

I recently designed a time series module where my time series is essentially a SortedDictionnary<DateTime, double>. Now I would like to create unit tests to make sure that this module is always ...
9
votes
8answers
1k views

A good schema to represent integer numbers from 0 to infinity, assuming you have infinite linear binary storage?

I would like a schema to represent integer numbers starting with 0, without any limit (assuming access to infinite linear storage). Here's a schema that can represent numbers from 0 to 255: Use the ...
2
votes
3answers
310 views

What implementation do you use when dealing with operators in .Net?

My question is in a sense a follow up of this post on Time Series in .Net. Ideally, you would like to expand the basic TimeSeries<T> class by something like NumericTimeSeries<T>, where ...
0
votes
2answers
3k views

complex numbers in programming?

Are complex numbers used in programming? If they are what is their significance? What IDEs and languages use them? And would it be recommended to learn how to implement them for a programming job (if ...
49
votes
11answers
8k views

Get 100 highest numbers from an infinite list

One of my friend was asked this interview question - "There is a constant flow of numbers coming in from some infinite list of numbers out of which you need to maintain a datastructure as to ...
5
votes
5answers
3k views

How do random number generators work?

I am a Programmer out of Oregon, I currently work as a web developer for a local company, and am starting college this winter for Computer Science. I was just pondering about php rand() function, and ...
12
votes
6answers
1k views

any document which says exactly what range of numbers are .NET BigIntegers designed for?

I'm playing around with the .NET BigInteger and basically I'm wondering what number --an estimated answer would be fine-- is the point of deviation of the curve of (the graph of (increase of time ...
1
vote
3answers
190 views

Does printing out numbers involve converting the numbers into characters?

In programming languages, when numbers (either integer, or real) are printed out, are they firstly converted to the codes of the readable characters that are meant to represent the numbers, and then ...
4
votes
5answers
1k views

sets of numbers that sum to a certain number?

I was asked this in an interview, and I'm not sure what the answer is or how to approach the problem. Find a pair of numbers that sum up to zero (or any other number), then find three (and then ...
23
votes
3answers
16k views

Why is 2^16 a “special” number?

OK, I feel stupid asking this - but in Jeff's article: Getting the Interview Phone Screen Right and originally stated in the 5 essential phone screen questions: They shouldn't stare blankly at you ...