Search code examples
llvmllvm-clang

Print Fixed Decimals using errs() in llvm


How to print fixed point decimals using errs() output stream of llvm.

For example if now if am doing errs()<<3.3; it is showing in scientific notation. I want it in decimal notation. I don't want to print with cout, but with errs


Solution

  • You can use the format function from include/llvm/Support/Format.h to create C-printf-like strings:

    errs() << format("%.3f\n", 3.3);
    

    etc.