You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Of course you're right. But I'll repeat. For 99.9% of tasks it is absolutely correct to replace rounding functions with alternative faster variant using conversion of fractional types to (int) or (long). An experienced programmer should be aware of this fact and apply it when it is expedient.
In 99% of cases there is no need to bother with rounding at all. For price comparisons I have this nonsense:
You may notice that in most cases it won't come to round() at all, although I haven't measured the speed.
see above
when x = 3 (any integer) there is a jam :))
Respectfully.
Is there a bug in mine or in your formula?
Respectfully.
In my old one:
and in yours:
when x=3 in both cases will be the wrong value of 4
and the variant:
is so far the most correct while maintaining maximum speed of execution.
In my old one:
and in yours:
at x=3 in both cases there will be an incorrect value of 4
and in case of variant:
is so far the most correct while maintaining maximum speed of execution.
but why do you need this formula when you give an integer to its input?
P.S. you need to understand, if you want to be a good programmer, that not everywhere and not always you need to shove all sorts of accelerating functions, it depends on the task at hand and the algorithm you're working with.with respect.
Why do you need this formula when you give an integer to its input?
Sincerely.
You may not know whether it is an integer or a non-integer. There are times when a double number can become an integer.
P.S. You have to understand, if you want to be a good programmer, that not everywhere and not always you need to shove all sorts of accelerating functions, it depends on the task at hand and the algorithm you are working with.
You may not know whether it is an integer or a non-integer. There are times when a number can become an integer.
Respectfully.
P.S. double by definition cannot be an integer, the representation of a number in machine memory will not change.Then you have to make a big deal about your choices of numbers on the input.
respectfully.
that's why, so we don't have to make a big deal out of it:
It's easier to write:
or this.
so you don't have to make a big deal out of it:
it's easier to write:
1-0.9999999999999998
you won't get it right.
With this approach, you can find a number at which your formula will not work.
Respectfully.
at
It's not going to work.
With this approach, you'll find a number at which your formula won't work.
Respectfully.
I've already written about it here.
I suggest you reread this thread so you don't repeat yourself.