Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Addition gone wrong
#3
(08-20-2025, 08:27 PM)Dimster Wrote: My code is extremely long and convoluted, so I'm just wondering if anyone has any ideas of where I should look to solve a simple addition problem.

Here is the jest of the math and values which are not adding up correctly

Code: (Select All)
Mean = .3061225
MF = .0000001
CycleValue = Mean + MF
Print CycleValue

So the above code works fine, CycleValue will equal .3061226 but that same addition in my program comes up with CycleValue = .3061225. I'm at a loss to understand why this addition of .0000001 will not take, and not sure where to look in my program that might be the culprit which prevents this simple addition. The value of Mean is dynamic in that there are multiple Cycles but that Mean Factor (MF) stays a constant .0000001. 

Any ideas as to what's going on?
bPlus's suggestion is what I would have said too.   But he didn't provide an explanation.     Floating Point Math on machines has a precision limit.   Your result is currently chopped because your exceeding that precision limit for a TYPE SINGLE (The Default type).   

DIM Mean as double
DIM MF as double
DIM CycleValue as DOUBLE 

Do this first.   If that doesn't work then try _FLOAT instead of double.  That has even more precision and range.
Reply


Messages In This Thread
Simple Addition gone wrong - by Dimster - 08-20-2025, 08:27 PM
RE: Simple Addition gone wrong - by bplus - 08-20-2025, 08:31 PM
RE: Simple Addition gone wrong - by ahenry3068 - 08-20-2025, 09:14 PM
RE: Simple Addition gone wrong - by SMcNeill - 08-20-2025, 11:15 PM
RE: Simple Addition gone wrong - by ahenry3068 - 08-20-2025, 11:47 PM
RE: Simple Addition gone wrong - by bplus - 08-21-2025, 06:30 AM
RE: Simple Addition gone wrong - by SMcNeill - 08-21-2025, 04:51 AM
RE: Simple Addition gone wrong - by Dimster - 08-21-2025, 03:09 PM
RE: Simple Addition gone wrong - by bplus - 08-21-2025, 03:45 PM
RE: Simple Addition gone wrong - by SMcNeill - 08-21-2025, 04:09 PM
RE: Simple Addition gone wrong - by bplus - 08-21-2025, 07:16 PM
RE: Simple Addition gone wrong - by Jack - 08-21-2025, 09:38 PM
RE: Simple Addition gone wrong - by Pete - 08-22-2025, 09:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Nice simple, I hope, question Mad Axeman 4 361 12-20-2025, 09:28 PM
Last Post: SMcNeill
  Trying to create a simple menu CMR 8 1,240 06-18-2025, 06:59 PM
Last Post: CookieOscar
  What is wrong with this for/next loop Helium5793 6 1,150 04-15-2025, 05:11 PM
Last Post: Kernelpanic
  Either I'm doing MID$( wrong or it has a bug TDarcos 4 813 04-13-2025, 11:14 PM
Last Post: TDarcos
  Simple Brick Pattern Fill Question NakedApe 3 918 12-01-2023, 09:37 PM
Last Post: NakedApe

Forum Jump:


Users browsing this thread: 1 Guest(s)