Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow 2 decimals for energy amount #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbaron-mx
Copy link
Contributor

This PR fixes a rounding problem caused by having the amount column defined as float(8,1), where if decreasing the energy by 0.25 for instance, it will be persisted to the database as 0.20

Issue can be recreated in Tinker as follows:

# Add energy of 1 to an energisable model
$hashtag->addEnergy(1);
$hashtag->energy->amount; // 1.0

# Decrease energy by 0.25
$hashtag->decayEnergy(0.25)
$hashtag->refresh(); 
$hashtag->energy->amount; // 8.0 instead of 0.75

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant