Skip to content
Advertisement

Tag: decimal

Binary to Decimal 32bit signed with PHP

I currently have a Decimal that is coming through as: 4294960896 This is then converted to Binary with this function: Which equals: 11111111111111111110011100000000 I then need to take that binary and convert it to the 32bit signed version which should be ‘-6400’ I can’t seem to find any built in functions that support 32bit signed output. Answer The hexadecimal representation

Incorrect PHP calculation

Can someone give me an explanation on why this is happening in PHP: It’s probably very simple but logically I do not see any explanation. Probably how PHP works in the background. I was trying to get the first two decimal positions of a number when I ran into this case. Result should be 29 naturally. If I round the

Decimal validation + PHP?

How to do decimal number validation in PHP? (The decimal point is optional) it should accept … 0 , 1 , 2 , 0.123 , 0.2 , 12.34 etc. Answer Would any of these suit your needs? is_float() is_numeric()

Advertisement