The Chapel counterpart is writef(), see:

    
https://chapel-lang.org/docs/modules/standard/IO/FormattedIO.html#FormattedIO.writef

The formatting for reals is discussed here:

    
https://chapel-lang.org/docs/modules/standard/IO/FormattedIO.html#real-conversions

If "%er" does not work when you pass an int to it, cast your int to real, like

    writef("%er", bignum:real);

BTW this makes for a perfect StackOverflow question with a "chapel" tag. Would 
you mind posting it there so we can respond?

Vass

-----Original Message-----
From: Tyler Simon <[email protected]>
Date: Monday, July 22, 2019 at 12:01 PM
To: "[email protected]" 
<[email protected]>
Subject: [Chapel-developers] writeln formatting

Greetings,

Simple question, taking your example for factorials, how would I need to change 
writeln to print out the correct value for say 150! in exponential form, in C 
would be printf("%le", bignum);


Or you could point me to where this is in the documentation?


Regards,

-Tyler


proc factorial(x: int) : int{
  if x < 0 then
    halt("factorial -- Sorry, this is not the gamma procedure!");

  return if x == 0 then 1 else x * factorial(x-1);}writeln("A simple 
procedure");writeln("150! is ", factorial(150));writeln();




_______________________________________________
Chapel-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-developers

Reply via email to