Bigger than Float ?

Monkey Forums/Monkey Beginners/Bigger than Float ?

golomp(Posted 2014) [#1]
Hi,

For a projection program i need to calculate some exponential values.

But at i arrived at Float limit and the actual result i obtain is 0.

So my question is : is there a possibility for monkey to manage with bigger values than Float ?

I know in other langages there is "long" suffixe wich extend number limits.

Is there an equivalent for Monkey ?

Thank you for helping.

P.S. : the trick to use 1.0 for factor dont give a better result


Gerry Quinn(Posted 2014) [#2]
I don't know if anyone has made a longint class. But it seems like you want floating point values anyway.

One option is to roll your own floating point class that holds the mantissa in a float and the exponent separately in an int. That way the exponent can grow as large as you are likely to want,


golomp(Posted 2014) [#3]
Hi Gerry,

Thank you.

Yes a multi precision library could be a solution. Maybe also a faster solution is to transform the function i want to analyze.

I was just asking if Monkey have the possibility to handle bigger data size. (I ask maybe too much to Monkey, i use Monkey for everything and i forget it's a software to create games, not to make mathematic analyzes)


skid(Posted 2014) [#4]
Are you sure it's not your code? If you test with the html target all floats are doubles.


TeaBoy(Posted 2014) [#5]
I'm no expert (far from it) but could it be more of a platform issue?


ImmutableOctet(SKNG)(Posted 2014) [#6]
If you're using the C++ Tool (STDCPP) target, then you could use the 'CPP_DOUBLE_PRECISION_FLOATS' preprocessor variable. That's about it, though.

I have made some edits to Monkey's compiler in the past for platform-specific data types, but I haven't looked into implementing this in a while. I honestly think Monkey should allow platform-dependent types as an option (Simply have the compiler configure if/how the types will be dealt with, if at all). I actually ended up making a module for backward compatibility for the language extensions I wanted. Some of my modules already integrate this module, and when I get around to implementing platform-specific extensions, my modules would see benefits. At some point, I think I'll come back to this idea. The idea of pointers in Monkey (Mainly for external code and lower-level memory management) was also something I wanted to toy with. I was also thinking of something similar to C#'s 'struct' system (Could actually work reasonably well with some work).

The big issue with such extensions is portability. There's a reason a number of BlitzMax users haven't jumped ship (Along with BlitzMax still being a solid product). A lot of developers want to use the hardware they're given to the fullest extent. I don't blame them. And to some extent, I agree with them. But the fact is, the closer you get to the metal, the less portable your games are. That being said, I think Monkey should give the option to work with hardware more intricately. However, I'm fine with the standard version of Monkey not supporting these extensions, because it's not something that's necessarily Monkey material.

Basically, if you need better floating-point accuracy, you'll need to either make/use a target which defines 'Float' as something more accurate, or modify Monkey's compiler.


Gerry Quinn(Posted 2014) [#7]
Or make a new class of extended precision floats. It doesn't seem like it should be all that complex.


golomp(Posted 2014) [#8]
I am going to extract my code and data to show you.

I think i rised the mathematical limit because all previous data calculation was right and now it doesnt.

For information it's a html5 build.

I prepare a sample and i post it.

Thank you


golomp(Posted 2014) [#9]
While preparing my sample i found my error. Float was not involved. Sorry...

My error was in the function i made to add values in my data array.

This function use Integer type parameters and the data to manage was higher than integer max value. (max int)

Shame on me :(


Gerry Quinn(Posted 2014) [#10]
NP, happens us all!


golomp(Posted 2014) [#11]
Thank you Gerry