Skip to main content

Questions tagged [numbers]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
231 votes
8 answers
300k views

When do you use float and when do you use double

Frequently, in my programming experience, I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels ...
Jakub Zaverka's user avatar
4 votes
3 answers
5k 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 ...
Matthijs's user avatar
  • 167
86 votes
6 answers
20k views

Why are floats still part of the Java language when doubles are mostly recommended instead?

In every place I've looked, it says that double is superior to float in almost every way. float has been made obsolete by double in Java, so why is it still used? I program a lot with Libgdx, and ...
Eames's user avatar
  • 885
10 votes
7 answers
15k 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 ...
GusDeCooL's user avatar
  • 212
13 votes
9 answers
5k views

Why are unsigned numbers implemented?

I can't figure out why microprocessor systems implement unsigned numbers. I guess the cost is just double the number of conditional branches, since greater than, less than, .etc, need a different ...
jtw's user avatar
  • 155
2 votes
4 answers
6k views

Understanding binary numbers in terms of real world objects [closed]

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 ...
Kaushik's user avatar
  • 1,195
1 vote
3 answers
361 views

Generate random numbers with certain spikes? [duplicate]

I am trying to generate random numbers to simulate steering wheel angles and velocities of a car. So for steering wheels the random numbers could go like 1,2,4,6,4,3,40,0. I can generate random ...
zzzzz's user avatar
  • 227