Hi, I am trying to create a function for C Code based on my Matlab function for rounding up a value to a user-defined variable.

I understand that you can use the Ceil function to round up when using printf, but as I am not displaying a lot of my calculations in the console I am looking for another method.

Below is an example of what I am trying to acheive:

Any help would be greatly appreciated!

% Function to round up a number to the specified decimal place
function return_value = ROUNDUP(value, decimalPlaces)
% Round the incoming value
count = 0;
magnitude = 1;
for count = 0 : decimalPlaces
magnitude = magnitude * 10;
end
return_value = ceil((value * magnitude) / magnitude);