Micro Focus QTP (UFT) Forums
how to get mantissa and decimal part - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: how to get mantissa and decimal part (/Thread-how-to-get-mantissa-and-decimal-part)



how to get mantissa and decimal part - Ishul - 03-25-2012

Hi All,

I have a decimal number 4.5, if decimal part less than 0.5 it should display
4, if decimal part greater than 0.5 it should display then next number 5.
without using built in function.






Thanks in advance
Hi All,

I have a decimal number 4.5,

if in that number , if decimal part is >0.5 it should display number as 4
and if the decimal part is <0.5 it should display number as the next number 5
how to do this without using built in functions.



Thanks in advande


RE: how to get mantissa and decimal part - sshukla12 - 03-26-2012

Hi,

U can create a function that splits ur number. Get the number after decimal part if its <5 then display the 4 as result and if decimal part is > than 5 then add 1 in 4.
It would be a simple function. try this and let me know if u are facing some issues.

Regards,
Sankalp


RE: how to get mantissa and decimal part - swathi - 03-28-2012

Code:
Dim oNum  
oNum=4.5
oDecNum=oNum- int(oNum)  

oDeccpart=.5
If oDecNum > oDeccpart   then
oNum=int(oNum)
msgbox  oNum
else
oNum=int(oNum)+1
msgbox  oNum
end if

Please check the above code.


RE: how to get mantissa and decimal part - Surya - 03-28-2012

Try this as well

Code:
oNum = 4.5
If Split(oNum, ".")(1) > 0.5 Then
  Msgbox Int(oNum)
Else
  msgbox Int(oNum)+1
End If