# Questions tagged [floating-point]

For challenges which are specific to numbers represented in floating-point format.

25 questions
Filter by
Sorted by
Tagged with
325 views

### KotH - Floating Point Prisoners Dilemma

Background So, nowadays the popular Prisoner's Dilemma variant is the Prisoner's Trilemma, where there are three options. I can easily see that being increased, so I figured Why settle for three ...
890 views

### Best Rolling Ao5

In speedcubing, an Ao5 (Average of 5) is computed for a set of five times by removing the fastest and slowest times, and then computing the mean of the remaining three times. A "rolling ao5" ...
2k views

### Implement Ash's float division

Ash has a bit of an interesting float division algorithm. It's designed to never return NaN, and things like signed zero and infinity need to be handled. How it ...
2k views

### Display the exponent from a binary floating point number as a decimal value

Had my software final exams recently, one of the last questions had me thinking for a while after the exam had finished. Background IEEE754 numbers are according to the below layout The exponent is ...
956 views

### Scientific notation in Base-16

Input a scientific notation number (base 10), output scientific notation in base 16 (as defined below). Details In scientific notation, all non-zero numbers are written in the form $$m \times 10^n$$ ...
1k views

### Convert Planck unit to SI metric

Objective Given a dimension of an SI unit, convert the Lorentz-Heaviside version of a Planck unit $1$ into SI metric. What is a Planck unit? Planck units are a set of units of measurement. It ...
5k views

### How far should I sum?

The harmonic series is the "infinite sum" of all the fractions of the form $\frac1n$ for $n$ positive integer. I.e. the harmonic series is \frac11 + \frac12 + \frac13 + \frac14 + \...
336 views

### Approximating the amount of prime numbers below x

Background We define the prime-counting function, $\pi(x)$, as the number of prime numbers less than or equal to $x$. You can read about it here. For example, $\pi(2) = 1$ and $\pi(6) = 3$. ...
6k views

### Floating Point XOR

Your task is pretty simple. Given two floats, bitwise xor the binary representation of them, and output that as a float. For example, ...
357 views

### Floating over the integers

As you may know, the typical binary floating point numbers in a computer language are quite different than the typical integer numbers in a computer language. Floating point numbers can represent a ...
856 views

### Decimal Digit Truncating

Input: A decimal Output: The input truncated How to truncate them? The integer part of the input will remain the same. The decimal part of the input will be truncated based on the lowest digit in ...
725 views

### Finding Factorials with Gamma [duplicate]

Introduction We know that the factorial notation is valid for all natural numbers. However, Euler had extended it for all positive real numbers, as well as for complex numbers by defining a function, ...
295 views

### Selling electricity

Jack is a little businessman. He found out a way to earn money by buying electricity on days when it's cheap and selling it when it's much more expensive. He stores the electricity in a battery he ...
1k views

### Output with the same number of digits of pi as the length of the code

Your challenge is to print x digits of pi where x is your code length. Examples: ...
2k views

### Float 754 to Hamming

You will be given as input an integer k in the range from -4503599627370496 (−252) to ...
264 views

### Find the Closest Double Palindrome

Given a double-precision float, find the closest double-precision float whose binary representation is a palindrome. Input A floating point number x. You may use ...
274 views

### Floor implementation

Target: Write a floor() function from scratch. Manipulating like converting float to string, and cutting all after dot are allowed. All languages are allowed. ...
2k views

### Decimal Time of Day Conversion

Introduction Time is confusing. Sixty seconds to a minute, sixty minutes to an hour, twenty-four hours to a day (and not to mention that pesky am/pm!). There's no room for such silliness nowadays, so ...
423 views

### Format a floating point number exactly as decimal

Any binary floating point can be formatted exactly in decimal. The resulting string might be somewhat long, but it is possible. In my article on floating point I cover the importance of precision, and ...
1k views

### Compute the shortest decimal representation of a IEEE 754 double-precision binary floating-point number

Format The format is a 64 bit value x representing a IEEE-754 double-precision binary floating-point number (a.k.a "a double"). x is assumed to represent a real number (not a NaN or Infinity). Goal ...
566 views

771 views

### Implement an IEEE 754 64-bit binary floating point number through integer manipulation

(I've tagged the question "C" for the time being, but if you're aware of another language that supports unions, you can also use that.) Your task is to build the four standard mathematical operators <...
2k views

### Fast inverse square root

Inspired by http://meta.codegolf.stackexchange.com/questions/547/write-a-code-golf-problem-in-which-script-languages-are-at-a-major-disadvantage question on meta, I've decided to make a question which ...