Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tweak Str$ for single and double
#2
Just two problems with this type of solution to floating point values:

Code: (Select All)
Dim As Single x
Dim As Integer y
For x = 1 To .05 Step -.05
    Print x
Next x


Sleep

Cls
y = 100
For x = 1 To .05 Step -.05
    Print x, y / 100,
    If x = y / 100 Then Print "EQUAL" Else Print "NOT EQUAL"
    y = y - 5
Next x


1) You're not actually changing the values.  Just how they're displayed -- in this case you can see they actual values themselves don't match up between X and Y after the sleep statement.

2) The formatting and display gets all wacky once dealing with different variables inside that same PRINT statement.  The output for the second set of code after the SLEEP looks nothing like the code from before the SLEEP.  Extra zeros get tacked onto everything, and the value for one somehow has a nice 0998(something) trailing after it for X.


[Image: image.png]



I wouldn't necessarily call the above an improvement.
Reply


Messages In This Thread
tweak Str$ for single and double - by Jack - 12-01-2022, 02:09 AM
RE: tweak Str$ for single and double - by SMcNeill - 12-01-2022, 03:08 AM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 04:20 AM
RE: tweak Str$ for single and double - by Jack - 12-01-2022, 12:17 PM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 02:09 PM
RE: tweak Str$ for single and double - by Jack - 12-01-2022, 02:19 PM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 02:24 PM
RE: tweak Str$ for single and double - by Pete - 12-01-2022, 03:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Splitting REALLY *REALLY* long lines into single character + CR + LF Circlotron 10 1,565 04-22-2025, 11:30 AM
Last Post: Circlotron
  double error Jack 1 636 08-16-2024, 08:43 PM
Last Post: Pete
  Integer (math) Single = Single SMcNeill 0 558 10-20-2023, 12:16 AM
Last Post: SMcNeill
  double to 2^53 Jack 4 935 05-03-2023, 08:31 PM
Last Post: Jack
  Reading a single value from Registry (Win) euklides 1 698 06-06-2022, 02:41 PM
Last Post: euklides

Forum Jump:


Users browsing this thread: 1 Guest(s)