# Math error with 2024.1.0

**URL:** <https://scilab.discourse.group/t/math-error-with-2024-1-0/584>\
**Category:** Graphics and plotting\
**Created:** [July 5, 2024, 4:54pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584 "2024-07-05T16:54:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Steve](https://scilab.discourse.group/u/Steve)\
**Post date:** [July 5, 2024, 4:54pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/1 "2024-07-05T16:54:04Z")

</div>

Hi guys,  
It’s a trivial but completely unnecessary error that is causing me trouble with data tips after tight crop  
 ![image](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/11200f1b56d1b8bf5db213d3f486d76e5a6d2ea6.png)  
Also shows up on 2024.0.0

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [July 5, 2024, 7:09pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/2 "2024-07-05T19:09:18Z")

</div>

Helllo,

This is not a math error, this is just reality of finite 52 bits mantissa coding of IEEE754 numbers.

Welcome to the real world (cit. Morpheus)…

S.

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [July 6, 2024, 3:46pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/3 "2024-07-06T15:46:34Z")

</div>

Look at the last 52 bits of the binary representation of numbers above

```scilab

--> bitstring([15.025; 13.375])

 ans = [2x1 string]

  "0100000000101110000011001100110011001100110011001100110011001101"
  "0100000000101010110000000000000000000000000000000000000000000000"

```

15.025 has a periodical truncated development, whereas 13.375 is exactly encoded.  
The substraction of the two above encoded numbers yields a different number than encoded 1.65:

```scilab
--> bitstring([15.025-13.375; 1.65])

 ans = [2x1 string]

  "0011111111111010011001100110011001100110011001100110011001101000"
  "0011111111111010011001100110011001100110011001100110011001100110"

```

you clearly see that the difference of the mantissa is exactly 10, which is the encoding of

```scilab
--> 2^-51

 ans = 

   4.441D-16

```

S.

---

<div class="post-metadata">

**Author:** ![Steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Steve](https://scilab.discourse.group/u/Steve)\
**Post date:** [July 6, 2024, 11:10pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/4 "2024-07-06T23:10:41Z")

</div>

## Thanks Mottelet, Yes, that is about what I figured. Here is the problem: first it was negative 13.375-15.025. I put it in positive form to simplify what was happening. That error ended up in an xpoly dimension. Still ok. Then later I read the xpoly data and placed a data tip in that location. Still ok. Then I used that poly data to tight crop the drawing at that location, which was y min by putting it in ax.data\_bounds Not ok. The data tip was off the edge (not visible) When I subtracted an addition 1e-15 from the data\_bounds (for example) it showed up fine. You have made clear why this is normal. Your explanation makes perfect sense, but it is still an error. That error is not a problem in itself, but the working together as I described above is an actual use problem. data\_bounds accepts and stores the number, but apparently does not use the -4.44089210D-16 error to set the actual bounds of the drawing. In the following demo I used the lower left x number: Setting bounds with a1.data\_bounds(1,1)=13.375-15.025; ![image](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/72485dbef9559d237431662e8a1b4368d9e5ddcc.png) Setting bounds with a1.data\_bounds(1,1)=13.375-15.025-1e-15; ![image](https://global.discourse-cdn.com/free1/uploads/utc/original/1X/84de0a58c06aa5a2b786cae9d5e389f9a0d31d22.png)

So, the error is normal but I think the problem it creates is unexpected. There are various ways of solving it with code, but I think it is not normal, so not something that would be designed into the code in advance.  
(BTW, I have no idea why my text is bold. I set it to bold, then removed it, but it stuck)

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [July 7, 2024, 2:46pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/5 "2024-07-07T14:46:20Z")

</div>

Hello

Please post a simple/minimal piece of code exhibiting the problem.

S.

---

<div class="post-metadata">

**Author:** ![Steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Steve](https://scilab.discourse.group/u/Steve)\
**Post date:** [July 7, 2024, 4:23pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/6 "2024-07-07T16:23:25Z")

</div>

Mottelet,  
I can reproduce on the original program with no problem, but I have not been able to duplicate with a simplified version.  
Obviously it is too simple. I’ve left the thing off that is exposing this. That could mean that it is an avoidable code choice.  
I’ll dig into this further and get back to you

---

<div class="post-metadata">

**Author:** ![Steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Steve](https://scilab.discourse.group/u/Steve)\
**Post date:** [July 7, 2024, 7:31pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/7 "2024-07-07T19:31:13Z")

</div>

Here it is. My original premise, that it was due to the math error, may be incorrect. The top two data tips don’t show up. Afterwards enter this command: a.data\_bounds(1,2)=-1.65-1e-15;  
And they show up. Also changing the numbers around, like changing out to make ymax 17 instead of 16, makes the problem go away. Likewise changing ymin by ± 1e-15.  
I still believe its an actual problem, but I’m a little baffled about the root cause.

```auto
close
clear;
clc;

out.xy =	[-2,	-1.65;
					2, -1.65;
					2, 16;
					-2, 16]

xpoly(out.xy(:,1), out.xy(:,2), 'lines', 1);
o = gce();
a = o.parent;
f = a.parent;

for idt = 1:4
	d(idt) = datatipCreate(o, idt);
end

a.tight_limits = 'on';

```

---

<div class="post-metadata">

**Author:** ![mottelet](https://yyz2.discourse-cdn.com/free1/user_avatar/scilab.discourse.group/mottelet/32/13_2.png) [@mottelet](https://scilab.discourse.group/u/mottelet)\
**Post date:** [July 8, 2024, 3:00pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/8 "2024-07-08T15:00:09Z")

</div>

Can you open an issue at [Issues · scilab / scilab · GitLab](https://gitlab.com/scilab/scilab/-/issues) ?

Thanks.

S.

---

<div class="post-metadata">

**Author:** ![Steve](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@Steve](https://scilab.discourse.group/u/Steve)\
**Post date:** [July 8, 2024, 11:15pm UTC](https://scilab.discourse.group/t/math-error-with-2024-1-0/584/9 "2024-07-08T23:15:01Z")

</div>

I just opened and issue #17273
