Hi,
I wish there would be predefined constants for all numeric data types. I know I can define them by myself, but I feel like this should be built-in.
#MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
#MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Re: #MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
And what should be the definition for #MinDouble in your opinion?
Code: Select all
#MinDouble = -1.7976931348623157081e308 ; smallest double greater than -Infinity
#MinDouble = 2.2250738585072013831e-308 ; smallest double greater than 0 with full precision
#MinDouble = 4.9406564584124654418e-324 ; smallest double greater than 0 with reduced precision
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: #MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
I'm interested in the use case. Where are you actually going to use the minimum and maximum values? Are you sure infinity isn't better? E.g. looking for minimum/maximum of something could start with infinity/-infinity.
bye,
Daniel
Daniel
Re: #MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
@STARGATE: Then the help is incorrect:
@DarkDragon: I'm using Doubles for my Gerber Module. Somtimes I have to find the lowest value from some (not predefined) operations. So initially I want to assign the highest value to my double. I surely can select a simply very high value, but using the highest value possible is much more elegant.
...or I miss something. Still, it would make sense for word, byte...The exact range of values, which can be used with floats and doubles to get correct results from arithmetic operations, looks as follows:
Float: +- 1.175494e-38 till +- 3.402823e+38
Double: +- 2.2250738585072013e-308 till +- 1.7976931348623157e+308
More information about the 'IEEE 754' standard you can get on Wikipedia.
@DarkDragon: I'm using Doubles for my Gerber Module. Somtimes I have to find the lowest value from some (not predefined) operations. So initially I want to assign the highest value to my double. I surely can select a simply very high value, but using the highest value possible is much more elegant.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: #MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
That's exactly where you'd use Infinity, e.g.jacdelad wrote: Wed May 01, 2024 4:28 pm@DarkDragon: I'm using Doubles for my Gerber Module. Somtimes I have to find the lowest value from some (not predefined) operations. So initially I want to assign the highest value to my double. I surely can select a simply very high value, but using the highest value possible is much more elegant.
Code: Select all
Minimum.d = Infinity()
ForEach Vertex()
If Vertex()\X < Minimum
Minimum = Vertex()\X
EndIf
Next
Debug Minimum
Special floating point numbers according to IEEE754
bye,
Daniel
Daniel
Re: #MinFloat/#MaxFlaot, #MinDouble/#MaxDouble...
Ah ok, that makes sense. Thanks for the hint.
Good morning, that's a nice tnetennba!
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD