How to display a float number in scientific? - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: How to display a float number in scientific? (/showthread.php?tid=2903) Pages:
1
2
|
How to display a float number in scientific? - desA - 08-04-2024 Good evening everyone, I would like display a float number in scientific mode to a set number of decimal places - for display printout purposes. E.g. 12345.6 -> 1.23E4 Please advise the appropriate command/s to do this in qb64pe. Many thanks... RE: How to display a float number in scientific? - Kernelpanic - 08-04-2024 For example: Code: (Select All)
Print Using RE: How to display a float number in scientific? - bplus - 08-04-2024 I am curious Code: (Select All) Print Using "##.##^^^^"; 12345.6789123 What do those "^"'s do? RE: How to display a float number in scientific? - Pete - 08-04-2024 (08-04-2024, 02:37 PM)bplus Wrote: I am curiousThey are tin foil hats to keep aliens from viewing your output! Actually: ^^^^ tells PRINT USING to print the answer in exponential format. Pete RE: How to display a float number in scientific? - Kernelpanic - 08-04-2024 As Pete has already written. Five ^ results in a three-digit exponent output - but then it's over. Sex is no longer acceptable! Code: (Select All)
RE: How to display a float number in scientific? - Pete - 08-04-2024 (08-04-2024, 03:03 PM)Kernelpanic Wrote: As Pete has already written. Five ^ results in a three-digit exponent output - but then it's over. Sex is no longer acceptable!That's why I avoid PRINT USING, so I don't miss out on 'sex'. I'm not sure what my latest string math post was, but I think this post included my way to convert to SI without using PRINT USING. https://qb64phoenix.com/forum/showthread.php?tid=756&pid=5236#pid5236 Pete RE: How to display a float number in scientific? - Kernelpanic - 08-04-2024 Quote:I'm not sure what my latest string math post was, but I think this post included my way to convert to SI without using PRINT USING.Yes, that's right! It works, programming-wise is it great, but what effort is involved . . .? RE: How to display a float number in scientific? - Jack - 08-04-2024 Code: (Select All)
RE: How to display a float number in scientific? - Kernelpanic - 08-04-2024 @Jack - It works and is not as complicated as Pete's solution. - A saying comes to mind: Why do it simply when one can do it complicated? Code: (Select All)
PS: I didn't find snprintf() in my C books, only here: snprintf() RE: How to display a float number in scientific? - Pete - 08-04-2024 Well guys, the whole idea behind BASIC is to figure out how to code it from scratch. PRINT USING relies on a builtin library, and Jack's neat example is a C library; so you really cannot ascertain matters of complexity when you are not really looking under the hood. Pete |