float 1.3 + 0.1 = 1.399999
Okay so what gives?
static const PLUGIN_NAME[] = "xxxx", PLUGIN_AUTHOR[] = "xxx", PLUGIN_VERSION[] = "1.3" new Temp[256]; formatex(Temp, 255, "addons/amxmodx/plugins/plugin%f.amxx",str_to_float(PLUGIN_VERSION)+0 .1); and it results in a file named plugin1.399999.amxx why? I want it to be 1.4 |
Re: float 1.3 + 0.1 = 1.399999
fixed by changing %f to %.1f and using floatadd(str_to_float(PLUGIN_VERSION),0.1)
|
Re: float 1.3 + 0.1 = 1.399999
I'd probably recommend using integers. One for the major version and one for the minor version.
However, I don't see any reason to have the full file path to a .amxx file but even more-so why you would need that of a future version. |
Re: float 1.3 + 0.1 = 1.399999
Floats are not precise enough and both 1.3 and 0.1 can not be accurately represented. By default the AMXX %f formatting will not round this small error away and will thus result in a 1.39999 being output (which is technically correct).
Your floatadd workaround does nothing, it is the %.1f formatting that "fixes" the issue. You can easily verify this using a small C program and printing the same numbers with something like %.12f so the numbers don't get rounded by the library. |
Re: float 1.3 + 0.1 = 1.399999
Quote:
I scaped the version usage tho, came up with a solution to overwriting the existing .amxx file even if it's being run by the server Quote:
|
Re: float 1.3 + 0.1 = 1.399999
just rename the plugin manually lmfao....
|
Re: float 1.3 + 0.1 = 1.399999
Quote:
|
| All times are GMT -4. The time now is 15:30. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.