separate a no.

Post your questions and help other users.

Moderator: Martin

Post Reply
apshergill91
Posts: 18
Joined: 07 Dec 2013 05:59

separate a no.

Post by apshergill91 » 31 Jan 2014 14:07

How do i split a decimal no [15.23] into its decimal and non-decimal part(i.e. 0.23 & 15 resp.)

REGARDS.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: separate a no.

Post by Martin » 31 Jan 2014 18:04

Hi,

You could use following script:

Code: Select all

number = 15.23;
n = "{number,numberformat,0}";//to format the number --> "15"
d = number - n;//15.23 - 15 --> 0.23
or

Code: Select all

number = 15.23;
d = number % 1;//modulo division by 1 --> 0.23
n = number - d;//--> 15.0 
Regards,
Martin

Post Reply