News:

Function Finder  Find all the functions within source code files

Main Menu

why can't i calc 2 variables to = floating point?

Started by stevmjon, September 13, 2015, 09:31:31 PM

Previous topic - Next topic

stevmjon

there are many times I need to calc 2 variables but I need the answer to be in floating point.
a# = b / c
a# = 50 / 100
a# = 0    *** would be handy if it would be floating point answer

it works if I put at least 1 floating point variable in the calculation.
a# = b# / c
a# = 50.0 / 100
a# = 0.5    *** correct

I know you can just use floating point calculations, but often I don't need to. I just want answer to be floating point.
I keep forgetting to use floating point variables in the calculation part, and wonder why the programs not working properly.
then I go doh.

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.

kevin

#1
  Original all operations were floats only in early VM's, but of course people found places where such behaviors created issues due to fpu's round mode  and it's quite a bit slower.  In languages like visible basic they have a integer division operator with the backward slash. \   There's really no way to do an integer division that produces a floating point result.      To do a floating point division, the data on both sides needs to pushed/cast to the FPU and div operation called.    

 Occasionally i'll still use fixed point.    Which is where you move the decimal point to the left a bits.    


 
  Also see:  Variable and Math Questions In PlayBASIC

stevmjon

fair enough, thanks kev.

floating point it is then

  stevmjon
It's easy to start a program, but harder to finish it...

I think that means i am getting old and get side tracked too easy.