Jump to content

is_inf() usage for sc_dt::scfx_ieee_float


anakin

Recommended Posts

Dear all,

I need to do floating point arithmetic in systemc. 

My question is if after I do two floating point addition or multiplication, can I call this api(is_inf()) for the sum or product to determine

it is inf or not? The produced results looks correct for me. 

Like the following sample code

```c

              num1.negative(sign1);
              num2.negative(sign2);
              num1.exponent(exp1);
              num2.exponent(exp2);
              num1.mantissa(significand1);
              num2.mantissa(significand2);
              //the additiion result
              result = num1+num2;
              cout.precision(23);
              cout << result.is_inf() << " " << num1 << " " << num2 << " " << result << endl;
 

```

 

The following are my test samples:

The first column is is_inf flag, the second and the third column are the source operands and the last column is the produced result.

```

1 -3.402823466385288598117e+38 -3.402823466385288598117e+38 -inf
0 0.5 -0.20000000298023223876953 0.30000001192092895507812
0 0.5 -9.9999997473787516355515e-05 0.49990001320838928222656
0 0.5 -0.30000001192092895507812 0.19999998807907104492188
0 0.5 100 100.5
0 0.5 2003 2003.5
0 0.5 100000 100000.5
0 0.5 -1000000 -999999.5
 

```

 

Any guidance is appreciate.

 

Link to comment
Share on other sites

This is a C++ question. SystemC is simply a library under C++. Floating point (double & float) are part of C++. There are some implementation bits with IEEE floating point in the current proof of concept source; however, this is not documented nor supported in the official standard presently. Whether or not the is_inf works as defined you could ascertain by examining the source code if you like, but really should not count on it.

If you have questions about fixed point types, those are addressed in the standard.

Please redirect your question to a C++ forum on the topic of floating point. Here is a link <http://www.cplusplus.com/reference/limits/numeric_limits/> of related interest.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...