I am trying to save a very large number to a yml.. number to save is -861031530247370120 and the number it saves as the key in the yml file is -1691235720 why is that? and is there a way to fix this or are numers that big not allowed in yml files? it works with a text file d:
Is your integer between the range of PHP_INT_MIN and PHP_INT_MAX? And also, what about casting the number to float first?
How can i see what the php int min is? i tried the constant..not recognized but the min is usaly just the same as the max but negative right? and max is 9223372036854775807 so min should be -9223372036854775807.. i am on windows 64 bit
Trying to write -1869275236685471920 ends up writing 2045615872... no matter what format i make the number. I have var_dump the int also to make sure it was right and it is.
I dont get it..that is inside of the php int limits. Is there some law with yml files? maybe ill take a stab at a db and see how that goes bc a text file wont work for what i need it for..it could but would be impractical lol
I think it is libyaml or the YAML extension that limited integers to 32 bits. No idea about the fact. Asked this question on stack overflow.
Is that a bug with YAML? and this means i cant use the Config::YAML? /: what type might be best for this? I decided to go with sqlite3 even tho i have no idea how to use it XD quickly learning tho..just having some issues getting all "primary keys" as array.
If you really need to save it, and the digits are consistent all the time, how about splitting it into two different floats, and put them together when you need it? (substr())
Im using clientId to create a tempban so no its never the same..didnt want to say bc its not "PocketMine"...but pm is inactive and genisys has a working UUID (the large int) that i am having loads of fun with XD i already got it all set with sqlite3 also, wasn't to hard to figure out. Also that wouldn't of been very practical either lol i was thinking of storing the uuid to a text file with the players name inside..then i could get the name/uuid that way and have the name in a yml saying how many days they have left of temp ban but that is all way to funky. Figuring out sql was more fun anyway
I tried that also i believe..and (float) $this->getConfig()->set((string)$id, array(yadayada)); when that didn't work i tried the strval
Can you show code? That is unreasonable; PHP shouldn't truncate a string as if it is an int. Wait, are you on 32-bit or 64-bit?
That code i sent there was just a example I am on 64 bit and have tried.. PHP: $id = $player->getClientId(); $now = date("Y-m-d"); $file = new Config($this->getServer()->getDataPath().'TempBans.yml', Config::YAML, array()); $file->set($id, [ 'Ban-On' => $now, 'Days-Left' => $days ]); $file->save(); output Code: 2045615952: Ban-On: "2016-03-17" Days-Left: "1" PHP: $id = (string)$player->getClientId(); $now = date("Y-m-d"); $file = new Config($this->getServer()->getDataPath().'TempBans.yml', Config::YAML, array()); $file->set($id, [ 'Ban-On' => $now, 'Days-Left' => $days ]); $file->save(); output Code: 2045615952: Ban-On: "2016-03-17" Days-Left: "1" PHP: $id = strval($player->getClientId()); $now = date("Y-m-d"); $file = new Config($this->getServer()->getDataPath().'TempBans.yml', Config::YAML, array()); $file->set($id, [ 'Ban-On' => $now, 'Days-Left' => $days ]); $file->save(); var_dump($id); // string(20) "-1869275236685471920" output Code: 2045615952: Ban-On: "2016-03-17" Days-Left: "1"
Oh, that's because PHP would automatically change array keys to integers if all array keys are numeric.
Ohh that would make sence lol but I still don't get why I can't set that big of a integer as a key to yaml..maybe I got the 32 bit binarys by mistake?..I believe I var_dump php_int_max tho and it was the 64 bit max.