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



Users browsing this thread: 2 Guest(s)