![]() |
Old code needs fixing (problem solved) - 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: Old code needs fixing (problem solved) (/showthread.php?tid=3081) |
Old code needs fixing (problem solved) - bplus - 09-27-2024 I got this from Steve at old forum and tested it today on problem encountered by Cortez at another forum. It does not work: Code: (Select All) ' !!!! 2024-09-27 this does not work Anyone have a better way of doing this? Cortez was testing Val() instead of N2S$() which didn't work either. Val has a bug also. RE: Old code needs fixing - Petr - 09-27-2024 I'm looking at it. Is it taken into account that Check 1 could be negative? How could that ever happen? After all, instr returns 0 or a positive value, so SGN is 0 or 1. Well, I keep looking, just apparently guessing what is expected from it. RE: Old code needs fixing - Kernelpanic - 09-27-2024 If I understood the explanation correctly, scientific notation should be displayed in a "normal" representation. How about that? Code: (Select All)
RE: Old code needs fixing - bplus - 09-27-2024 Print Using requires a number not string, could it do 1.23D-20? Looks like it throws in some BS on the end: Code: (Select All) print using "###.#######################################################################################################";1.23D-20 maybe Print Using combined with string("#", D or E amounts) in a function? Oh maybe the left number is not expected to be above 9.xxxx... ie < 10.000... and also > 1.0000... for proper Sci Notation. RE: Old code needs fixing - Kernelpanic - 09-27-2024 It works! ![]() RE: Old code needs fixing (problem solved) - bplus - 09-27-2024 The problem was not using proper Sci Notation. ![]() First number must be between 1 and < 10 and you have to use + for positive powers of 10. Code: (Select All) Print Val("1.1E+6") Code: (Select All) _Title "N2S$ Test Steve's converter for number display" ' b+ 2022-11-10 Also fine! RE: Old code needs fixing (problem solved) - SMcNeill - 09-27-2024 (09-27-2024, 09:31 AM)bplus Wrote: I got this from Steve at old forum and tested it today on problem encountered by Cortez at another forum. (09-27-2024, 02:26 PM)bplus Wrote: The problem was not using proper Sci Notation. ![]() ![]() ![]() It only works when the notation works. Pass it bad data, it returns bad results. There should've been a helper function with it somewhere called Function VerifyNum that makes certain your passing a valid number. It's a little complex and a lot of basic error checking, and as such I didn't make it part of the main process so that it could be easily bypassed for those times when you KNEW your data was valid and didn't want to add in those extra checks for processing delays. Back in the day, these routines were used for String Math routines, and as such reducing non-necessary error checking was an important thing to keep run time as quick as possible. If they're not certain the data is always in valid format, then you might need to hunt down that VerifyNum (or was it CheckNum??) routine and add it as a pre-check before running the N2S$ routine. ![]() |