Jump to content

How do I add decimal point to a number?


andyhajime

Recommended Posts

Hi guys,

 

I'm looking for a function to add 2 decimal point from a non-decimal number.

what function do i use to change 676865 to 6768.65.

I've use sprintf("%.2f","676865") but I get is 676865.00.

some dude elsewhere says to use "number_format($number,[number of decimal places]);" but I gotten 676,865.00 instead.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/91202-how-do-i-add-decimal-point-to-a-number/
Share on other sites

  • 1 month later...

That was the simplest method for ur requirement.But u should first determine whether the number is float or integer value.

 

The simples method is the best method. I'm actually looking for a quick solution so I can get the coding done. Besides, I really don't like a very long lined coding. They normally confuses me.  ;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.