Macro doesn't do basic math order

Hi,
I ran into a problem with my macro that I cannot seem to find the answer to.
This is the BASIC, and really basic code I have for it.

Function PPMCON(a)
PPMCON = (a/44.01)/1000
End Function

Now, initially I did not have the parentheses until I realized LibreCalc won’t do basic PEMDAS. Instead the program first divides 44.01 by 1000, and only thenn the variable “a” by it. I added the parentheses in hopes that maybe this will do the trick, but it didn’t.

Basically my question is - how should i write this code so it returns the correct value?
Thanks

Welcome!
What about PPMCON = a*2.272210861167916e-5 ?

This is something that e.g. I don’t see (expectedly). E.g.:

Function PPMCON(a)
PPMCON = a/44.01/1000
End Function

sub testPPMCON
  msgbox PPMCON(1)
end sub

Calling testPPMCON shows:
image

So - what specifically do you see, and for what input?

thanks, but that still doesn’t actually work, since the results i get only have a significant figure appearing at the second or third decimal place, could the program just be struggling with those numbers? the first two s.f. seem to fit with the results from my secondary sources

yeah, i think i accidentally boiled down the problem to the wrong reason, it’s actually not the wrong order, sorry
i think it might be the tiny numbers i get from my calculations, but i am not entirely sure

@gmilo Did I accidentally overlook your answer to this question somewhere?

You know, I have one crazy idea. This is unlikely, but needs to be checked. This function is quite small in size. If you have many modules with a lot of code, then somewhere among other procedures and functions the twin brother of this stubborn function may get lost. It turns out that you make changes to the code, expect some kind of reaction from the program, but nothing happens, because one instance of the function is corrected, and another is executed. Yes, it looks stupid - but I myself have found myself in such a ridiculous situation several times.

sorry, i didn’t answer, staring at walls of numbers for hours doesn’t do ones brain right.
okay so basically for example let’s take 437.3, i’ve checked in the ms calculator, google, wolfram alpha, and even pulled out my ti-84, all sources say the same thing, the results is 0.00991609773… etc. aaand what does libre says? 0.00993637… etc.
:\

Yes, that’s true - if the numbers don’t converge more than seven times in a row, then it’s time to sleep :slight_smile:

image

this might actually be the case, i opened up a new file, compiled the macro again, and all of a sudden the math is working
guess now i just gotta copy and paste tons and tons of columns all over
but it seems my problem was solved so, thank you very much!

Instead of dividing by 1000, try multiplying by 0.001. Solves the PEMDAS error.