E
E
Eugene Ordinary2019-11-30 12:59:58
Mathematics
Eugene Ordinary, 2019-11-30 12:59:58

Is it possible to artificially reduce the precision of real numbers in C++?

Is it possible to artificially reduce the precision of real numbers in C++? For example, so that representations of numbers, as well as all operations, occur with an accuracy of 3 significant digits. To illustrate numerical methods, rounding errors must be created, and they are usually very small. I want to do more than it was clearer and easier.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
Grigory, 2019-11-30
@Griglapidus

For 3 digits, you can multiply all data by 1000 and store in int64 and process it like this. and then divide by 1000

X
xmoonlight, 2019-11-30
@xmoonlight

1. Number to text
2. We cut the tail to the very face
3. Text to number

R
Roman Mirilaczvili, 2019-11-30
@2ord

There is half precision (16 bits), but there are even less.
https://www.johndcook.com/blog/2018/04/14/ieee-vs-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question