Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
rounding numbers and converting to string (hiding scientific notation)
#7
(07-25-2022, 06:18 PM)madscijr Wrote:
(07-18-2022, 07:16 PM)bplus Wrote: Here is a Round$ that acts the way you'd expect in under 100 LOC

Finally getting around to this... thanks!

One question about part of the code:
(07-18-2022, 07:16 PM)bplus Wrote:
Code: (Select All)
Function N2S$ (EXP$) 'remove scientific Notation to String (~40 LOC)
    ...
    ReDim t$, sign$, l$, r$, r&&
    ReDim dp As Long, dm As Long, ep As Long, em As Long, check1 As Long, l As Long, i As Long
    ...

Why ReDim instead of Dim?
I only ever use ReDim if I need to grow or shrink an array. 
But these don't seem to be arrays and are not ReDimmed later in the function, so is there any advantage for ReDim that maybe I don't know?
(I figure I might as well ask!)
Thanks again!

Good question,
According to Luke ( a developer of QB64.exe) and Steve or others may confirm, ReDim can be used anywhere you use DIM. Dim is the only command you want to use to make a Static array (cleared with Erase) unless you use Static itself.

So I modified that code (that came from Steve BTW) with REDIM's probably to make Option _Explicit happy back in the period when I was using REDIM for everything except Static Arrays. 

What I like about this is no Type worries for the number!
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
RE: rounding numbers and converting to string (hiding scientific notation) - by bplus - 07-25-2022, 09:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Converting input from other devices to standard PC gamepad analog input? madscijr 0 167 01-01-2026, 06:39 PM
Last Post: madscijr
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,185 12-19-2025, 12:51 PM
Last Post: Heimdall
  Sub not Reconizing Dim as String pmackay 18 1,452 10-16-2025, 03:32 PM
Last Post: pmackay
  Illegal string-number conversion Herve 7 759 07-07-2025, 09:53 AM
Last Post: a740g
  need help printing a scaled string in a custom font to a 32-bit image madscijr 9 1,148 07-03-2025, 04:48 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)