Hi Roman Zilber You are right instead of truncation, we will see rounded values.. sreedhar also made a good point users will know what function to use based on their requirements. Good conversation.. so far..
Thanks & Regards Sriniavs Pavuluru On Mon, Jun 8, 2009 at 3:31 PM, Roman Zilber <[email protected]> wrote: > FormatNumber rounds up the number. > > msgbox formatnumber("2.16",1) > ==> 2.2 > > > > > On Mon, Jun 8, 2009 at 3:26 PM, Sreedhar Mallipeddi < > [email protected]> wrote: > >> Good one...still u can use FormatNumber function in an vbs file or in >> qtp...Hope that is more easy.. >> >> >> >> >> On Tue, Jun 9, 2009 at 12:35 AM, Roman Zilber <[email protected]> wrote: >> >>> Ho! Sorry I didn't see about "I do not need rounding up." >>> >>> Function MyNonRoundUp(num, numOfDec) >>> tmp = 10 ^ numOfDec >>> MyNonRoundUp = INT(num * (tmp))/ tmp >>> End Function >>> >>> msgbox MyNonRoundUp(99.99, 1) >>> >>> >>> >>> On Mon, Jun 8, 2009 at 3:00 PM, Roman Zilber <[email protected]> wrote: >>> >>>> Since this discussion turns to be more and more interesting, here are my >>>> 5 cents: >>>> >>>> Function MyRound(num, numOfDec) >>>> tmp = 10 ^ numOfDec >>>> num = num + (5/(tmp * 10)) >>>> MyRound = INT(num * (tmp))/ tmp >>>> End Function >>>> >>>> msgbox MyRound(33.666, 2) >>>> msgbox MyRound(0.555, 2) >>>> msgbox MyRound(9.5, 2) >>>> msgbox MyRound(8, 2) >>>> >>>> >>>> On Mon, Jun 8, 2009 at 2:39 PM, Srinivas Pavuluru >>>> <[email protected]>wrote: >>>> >>>>> Some additional info.. from HP help.. >>>>> >>>>> >>>>> Returns the integer portion of a number. >>>>> >>>>> Int(number)*Fix(*number*)* >>>>> >>>>> The *number* argument can be any valid numeric expression. If >>>>> *number*contains Null, >>>>> *Null* is returned. >>>>> Remarks >>>>> >>>>> Both *Int* and *Fix* remove the fractional part of *number* and return >>>>> the resulting integer value. >>>>> >>>>> The difference between *Int* and *Fix* is that if *number* is >>>>> negative, *Int* returns the first negative integer less than or equal >>>>> to *number,* whereas *Fix* returns the first negative integer greater >>>>> than or equal to *number.* For example, *Int* converts -8.4 to -9, and >>>>> *Fix* converts -8.4 to -8. >>>>> >>>>> *Fix(**number**)* is equivalent to: >>>>> >>>>> Sgn(*number*) * *Int(*Abs(*number*)*)* >>>>> >>>>> The following examples illustrate how the *Int* and *Fix* functions >>>>> return integer portions of numbers: >>>>> >>>>> MyNumber = *Int(*99.8*)* ' Returns 99. >>>>> MyNumber = *Fix(*99.2*)* ' Returns 99. >>>>> MyNumber = *Int(*-99.8*)* ' Returns -100. >>>>> MyNumber = *Fix(*-99.8*)* ' Returns -99. >>>>> MyNumber = *Int(*-99.2*)* ' Returns -100. >>>>> MyNumber = *Fix(*-99.2*)* ' Returns -99. >>>>> >>>>> >>>>> Thanks >>>>> >>>>> Srinivas Pavuluru >>>>> >>>>> On Mon, Jun 8, 2009 at 2:35 PM, Srinivas Pavuluru < >>>>> [email protected]> wrote: >>>>> >>>>>> Hope you got the solution.. >>>>>> >>>>>> On Mon, Jun 8, 2009 at 2:33 PM, Srinivas Pavuluru <[email protected] >>>>>> > wrote: >>>>>> >>>>>>> Hi >>>>>>> >>>>>>> To get only numbers i mean integer values >>>>>>> >>>>>>> you can use >>>>>>> >>>>>>> mvalue = "2.12" >>>>>>> msgbox INT(mvalue) >>>>>>> >>>>>>> alwyas gives you the number >>>>>>> >>>>>>> Thanks >>>>>>> Srinivas Pavuluru >>>>>>> >>>>>>> >>>>>>> On Mon, Jun 8, 2009 at 2:29 PM, Srinivas Pavuluru < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> Hi >>>>>>>> >>>>>>>> you can also try following logic >>>>>>>> >>>>>>>> mvalue = "2.12" >>>>>>>> mvaluelen = len(mvalue) >>>>>>>> mactvalue = left(mvalue,mvaluelen-1) >>>>>>>> msgbox mactvalue >>>>>>>> >>>>>>>> Thanks >>>>>>>> Srinivas Pavuluru >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> On Mon, Jun 8, 2009 at 2:23 PM, Sreedhar Mallipeddi < >>>>>>>> [email protected]> wrote: >>>>>>>> >>>>>>>>> >>>>>>>>> hi >>>>>>>>> >>>>>>>>> use formatnumber("2.12",1) , it will give u the excepted result. >>>>>>>>> Replace 2.12 with ur value... >>>>>>>>> >>>>>>>>> Thanks, >>>>>>>>> Sreedhar >>>>>>>>> >>>>>>>>> >>>>>>>>> On Mon, Jun 8, 2009 at 10:30 PM, denka <[email protected]>wrote: >>>>>>>>> >>>>>>>>>> >>>>>>>>>> Hi, >>>>>>>>>> tried to search, did not find anything like that here. Anyways, >>>>>>>>>> maybe >>>>>>>>>> someone knows. >>>>>>>>>> I have numbers with decimals like 2.13 and 2.12. Is there a way to >>>>>>>>>> truncate decimals in those numbers? like to be 2.1. I do not need >>>>>>>>>> rounding up. Thank you in advance >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> -- >>>>>>>>> Mallipeddi Sreedhar >>>>>>>>> 91-9848871279 >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>> >>>>> >>>>> >>>> >>> >>> >>> >> >> >> -- >> Mallipeddi Sreedhar >> 91-9848871279 >> >> >> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google "QTP - HP Quick Test Professional - Automated Software Testing" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/MercuryQTP?hl=en -~----------~----~----~----~------~----~------~--~---
