Direct answer export to text type formats #97
-
My question is, is there any way to directly write the answer in a text file instead of the terminal shell, this app is great, but as I use it on termux it has Max 50000 rows any number larger than that can't be scrolled back, so I wanted this app to directly write the answer in a text file, question 2: can I set the precision of the output manually, like how many digits answers I get etc? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Hello @roshan-g20. Calc has a set of built-in functions that allow you to do file I/O. For general info on file I/O see:
FYI: The leading ";"'s in these interactive examples is just the interactive prompt of You may open, and create a new file or truncate an old file, as needed:
And then print values to that file:
The output of a large number may be subject to buffering, so you probably want to flush the output to be sure that your OS / libc streams are written to disk. So you may wish to follow the above
Or even close the file:
For more info see:
Write your own function to write values to a fileSee discussion 6757645 for an overview on calc resource files and user defined functions. You may use these to create your own "write to file" (or "w2f" for short system. For example, put in a file called
Assuming we made no typos (we are entering this via an iPad and not testing the code, so parson typos), you can do:
Again, please pardon ant typos in the above calc resource file. It was typed in, as we were entering this comment, by hand via an iPad. Hopefully it will give you a general idea, even with typos. :-) Converting large values to decimalIf a value a HUGE, computing the digits of a value in decimal can be TIME CONSUMING operation. Printing in octal (use "%o", hexadecimal (use %x") or binary (use %b) will be much faster than printing in base 10.
See:
for details about format strings. BTW: Printing non-integers in octal, hexadecimal or binary will print the internal faction of that value:
A quick way to get the memory size of a number is to use:
If the value is an integer, you can get an idea of the numerical size in bits. by printing the high bit position of a value:
As mentioned above, computing the digits of a value in decimal can be TIME CONSUMING operation. This applies to the
calc I/O summaryCalc a lots of file I/O related functions. Most of them start with "f". For a complete list of built functions, see:
Every function has its own help file, so for example:
Many give you hints about related functions in the "SEE ALSO section":
We hope this helps. |
Beta Was this translation helpful? Give feedback.
-
The
FYI: The leading ";"'s in these interactive examples is just the interactive prompt of IMPORTANT NOTE: The precision (think accuracy below the decimal point) must also be considered. Simply extending the number of digits to display may not produce digits or more accurate digits. The
Many functions take an optional epsilon value. For example, the 2nd call to
NOTE the "~" indicating that the value printed is rounded while being printed. The usual default value of To get more digits displayed, try:
NOTE the use of the trailing comma. When a "," follows an expression, function, variable, etc, the value returned is not displayed. Normally Now print your pi with more precision:
Again, to get more digits displayed after the decimal point, use the Again, to get more accurate digits after the decimal point, calculate with a greater precision by setting beforehand, the global epsilon using the
Again, you need to keep in mind BOTH the number of digits displayed after the decimal point as well as the epsilon precision of calculations. Of course, all the digits before the decimal point will always be printed, regardless of the value of
You may set certain things as a personal default a startup file according to the
Assuming that
And you could out, for example, this into your
The final ";" at the end of the line, terminates a command and separates it from other commands in the file. Again, NOTE the use of the trailing comma ",". This trailing comma prevents calc from printing the return values of those functions. FYI: See:
for info on what you can configure. We hope this helps. |
Beta Was this translation helpful? Give feedback.
Hello @roshan-g20.
Calc has a set of built-in functions that allow you to do file I/O. For general info on file I/O see:
FYI: The leading ";"'s in these interactive examples is just the interactive prompt of
calc
.You may open, and create a new file or truncate an old file, as needed:
And then print values to that file: