10.0 you mong
/dpt/ - Daily Programming Thread
but how do I simply push the number to the right, right now it simply adds my floats.
float result = stringToFloat(floatValue.toString() + intValue.toString());
You have much to learn. This might help:
leetcode.com
how do I get how many decimals a number has?
An integer? log 10, floor, add 1
holy shit your calculator program should not be storing and building its numbers in IEEE floating point format
the lazy option is to just build it by appending characters to a string and then calling tofloat or whatever. if you're serious about shit you should use an arbitrary-precision math library so you don't get shitty floating point rounding errors. it'll be much slower than floats but still billions of times faster than the human interface so it doesn't really matter
I'm making a basic calculator for dumb weebs who want some weeb calculator for mobile bro, with an android banner.
as i said
the minimum option is to simply store the inputted values as strings and call your language's string-to-float function at the last moment before calculation
don't try to do bit twiddling shit to add digits to the end of a decimal number because you're just going to run into rounding error after rounding error converting back and forth between base 2 and base 10 so often
>have flash of inspiration
>think of a very elegant way to do Thing
>halfway through implementing it start worrying about edge cases since they seem pretty hard to handle
>finish to core implementation and start testing for the edge cases
>realize the implementation actually handles them all correctly without any need for ugly edge case handling conditionals
I wonder if my brain knew this all along.