Display problem

In reply to timag:

Hello, just use the string methods atoreal. Here are the steps:

  1. Define a string, that you could eventually provide as input of an hypothetical function, which is going to represent the format. Let’s get up to the 3rd number after the binary point. Hence your string would be “0.2”.

  2. Use the $sformatf to get the final mentioned string, based on your previous example the expression would be: fstr=“%”,format,“f”; your_string_real=$sfomatf(fstr,real_number)

  3. After getting the string, use the real_truncated=your_string_real.atoreal().

4 now save the diff: diff = initial_number - real_truncated;

You can wrap up using a function or a macro is more up to you. This is the first approach coming up with I would go for so let me know if it works