-3
I need to arrive at the following result:
4,2 = 5
85,02 = 9
256,9 = 3...
For now, I’ve used the code:
$novoservico = '402,02';
$novoservico = str_replace(",",".",$novoservico);
$valor_redondo = ceil($novoservico);
echo $valor_redondo; ?>
With this code, I can always round up the numbers:
4,2 = 5
85,02 = 86
256,9 = 257...
In this case, I need to make these numbers "truncated up". I don’t know if I was very clear using this expression. But it was the best way to explain what I need to do. Thank you in advance. on any comment or doubt about the question, I am available.
85.02 = 9? This is not rounding.
– David Alves
@Davidalves is right, the system rounds to the nearest integer
– Wees Smith
The result you got is exactly the result you described you want to get, so the question made no sense.
– Woss
"but it only rounds numbers after the comma" - This is the concept of rounding.
– Isac
@Andersoncarloswoss he said he wanted 85 turn 9, I imagine he only wants 1-digit integers. But it was not clear
– David Alves
This makes even less sense. I voted to close as unclear until I have more information.
– Woss
I am a USER trying to program. You should have a slightly sharper critical sense. I’m sure you understand what I mean. Is it hard to try to help me? This is a forum for beginners and professionals. I’m starting in Stack Overflow. Being "received" that way is not nice. I appreciate the Wees help. I don’t want to be boring, just be upset with the comments. I think a forum is to help
– Raul Germano
@Raulgermano and everyone is trying to help you, if you got it wrong, it’s not our fault. Your question made no sense, so much so that all Those who read it were in doubt. Whether you are user or developer, beginner or advanced, doesn’t matter, but your question is unclear and demands more details. You were asked what you want to do and you didn’t answer, so how do you want to be helped like this? In question you say you need rounding to the whole above and your code does exactly that. If you want something different, edit ([Edit]) your question and describe the problem better.
– Woss
Let’s start over. I just finished editing
– Raul Germano
So starting over, we come back to the question: you need the result to be at all times only one digit, regardless of the magnitude of the input? If I enter with 10000000, must return 1, while I enter with 10000001 must return 2?
– Woss
Just so we’re clear This is not a forum and everyone is trying to help. " I’m sure you understand what I meant" - Certainly not, and you can see this by the amount of questions asked in the comments (I didn’t quite understand the result you were looking for exactly myself). What may be evident to you that is within the context is not always for others who are not in the same context.
– Isac