question

udaya avatar image
udaya asked ericnute edited

math function message shown is not correct wrt TCL

I am trying to convert an exponential value to integer value during test case execution. I used math funtion and observed a starnge response

step:

puts [math.int 5e+9]

output:

2147483647

 

But in the math convetion it should be 5*10^9 which is equal to 500000000 

 

Also, I tried the same in TCL shell(outside iTest and also iTest tcl) it is showing the message - "integer value too large to handle"

 

And particularly this message(s) are shown when the exponential is going equal or over 9.

 

This behaviour is aslo seen when I am trying to convert large hex numbers.

 

So, I can understand this is limitation of TCL here.

 

But the concern is the out put of the response. It should be handled properly and corrected otherwise it will definitely create a wrong mesage during automation.

 

This is always reproducible, anyone can try.

 

iTesttcl script
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
saicharan avatar image
saicharan answered saicharan posted

Hi Udaya,

 

 Yes , the response  message needs to be improved .

 I have tried with the same "math" function in iTest and ouside of the iTest(TCL shell) also , and it showing the response as posted by you .

 I  have logged a bug to internally track this issue..

 

Thanks,

Saicharan

3 comments
10 |950

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

udaya avatar image udaya commented ·

Thanks Saicharan! Cool:smileyhappy: 

 

I would also like to mention  the work around:

 

puts [format %f 8e+9] (say) -> it will show the response in floating/double number format.

 

Simply adding an analysis rule to that and storing the integer part in a variable be the quick resolution.

 

Hex values:

 

Instead of math function the exression would be:

 

puts [expr <hex_value>]

 


0 Likes 0 ·
rmehlinger avatar image rmehlinger udaya commented ·

Hi guys, the root of the issue is that 2147483647 is MaxInt, i.e., the largest value computers can store as a 32-bit integer. If you want to store a larger integer, we need to use a long (short for long integer). TCL has a function, math.wide, which does this, but it's not implemented in iTest 4.1.4. We've created a feature request, and hope to have it implemented soon. When it is, it will follow the TCL 8.4 syntax:

 

puts [math.wide 5e+9]

 

For the record, MaxLong (i.e., the highest value supported by math.wide) is 9223372036854775807.

1 Like 1 ·
udaya avatar image udaya rmehlinger commented ·

Great to be this :smileyhappy:

 

Thanks for the information!

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.