Incorrect result in Shader Node Math.Fraction #107518

Closed
opened 2023-05-01 23:48:20 +02:00 by Vladimir · 8 comments

System Information
Operating system: Linux-6.3.0-1-MANJARO-x86_64-with-glibc2.37 64 Bits, X11 UI
Graphics card: Mesa Intel(R) HD Graphics 4600 (HSW GT2) Intel 4.6 (Core Profile) Mesa 23.0.3

Blender Version
Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-04-30 05:23, hash: 358ce4f52b58
Worked: (newest version of Blender that worked as expected)

Short description of error

Blender official docs:
https://docs.blender.org/manual/en/latest/modeling/geometry_nodes/utilities/math.html
Fraction - Returns the fractional part of the value.

When I input float value equals 12.56 into Fraction, return 0.56, it is ok. But when I input a value equals -12.56 (negative sign), Fraction return value 0.43 !!!

Screenshot_20230502_002537.png

Exact steps for others to reproduce the error

**System Information** Operating system: Linux-6.3.0-1-MANJARO-x86_64-with-glibc2.37 64 Bits, X11 UI Graphics card: Mesa Intel(R) HD Graphics 4600 (HSW GT2) Intel 4.6 (Core Profile) Mesa 23.0.3 **Blender Version** Broken: version: 3.6.0 Alpha, branch: main, commit date: 2023-04-30 05:23, hash: `358ce4f52b58` Worked: (newest version of Blender that worked as expected) **Short description of error** Blender official docs: https://docs.blender.org/manual/en/latest/modeling/geometry_nodes/utilities/math.html **Fraction** - Returns the fractional part of the value. When I input float value equals **12.56** into Fraction, return 0.56, it is ok. But when I input a value equals **-12.56** (negative sign), Fraction return value 0.43 !!! ![Screenshot_20230502_002537.png](/attachments/e940a63e-709c-4de6-9faf-5cfa36d44788) **Exact steps for others to reproduce the error**
Vladimir added the
Priority
Normal
Type
Report
Status
Needs Triage
labels 2023-05-01 23:48:20 +02:00
Iliya Katushenock added the
Interest
Nodes & Physics
label 2023-05-02 08:10:26 +02:00
Member

Hi, thanks for the report. Don't think this is a bug. For me, this looks expected codewise and conceptwise.
To calculate the decimal part of any real number, the logic is to subtract floor number from the actual number.
i.e. x - floorf(x)
And remainder has to be positive always (if we consider 0.56 as a answer then it will be -0.56 which is incorrect).
Also see: https://math.stackexchange.com/questions/710018/fractional-integer-parts-of-a-negative-real

Will close this report. Feel free to comment if there is any misunderstanding.

Hi, thanks for the report. Don't think this is a bug. For me, this looks expected codewise and conceptwise. To calculate the decimal part of any real number, the logic is to subtract floor number from the actual number. i.e. x - floorf(x) And remainder has to be positive always (if we consider 0.56 as a answer then it will be -0.56 which is incorrect). Also see: https://math.stackexchange.com/questions/710018/fractional-integer-parts-of-a-negative-real Will close this report. Feel free to comment if there is any misunderstanding.
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-05-02 08:37:15 +02:00
Author

Hi, thanks for the report. Don't think this is a bug. For me, this looks expected codewise and conceptwise.
To calculate the decimal part of any real number, the logic is to subtract floor number from the actual number.
i.e. x - floorf(x)
And remainder has to be positive always (if we consider 0.56 as a answer then it will be -0.56 which is incorrect).
Also see: https://math.stackexchange.com/questions/710018/fractional-integer-parts-of-a-negative-real

Will close this report. Feel free to comment if there is any misunderstanding.

Hi!
I am not programmer, there it is code tier and I am user :) Fraction should be return fraction but not random value. Else, what is fraction?

Python:
math.modf(x)
Return the fractional and integer parts of x. Both results carry the sign of x and are floats.

>>> import math

>>> math.modf(10.5)
(0.5, 10.0)

>>> math.modf(-10.5)
(-0.5, -10.0)
> Hi, thanks for the report. Don't think this is a bug. For me, this looks expected codewise and conceptwise. > To calculate the decimal part of any real number, the logic is to subtract floor number from the actual number. > i.e. x - floorf(x) > And remainder has to be positive always (if we consider 0.56 as a answer then it will be -0.56 which is incorrect). > Also see: https://math.stackexchange.com/questions/710018/fractional-integer-parts-of-a-negative-real > > Will close this report. Feel free to comment if there is any misunderstanding. > Hi! I am not programmer, there it is code tier and I am user :) Fraction should be return fraction but not random value. Else, what is fraction? Python: math.modf(x) Return the fractional and integer parts of x. Both results carry the sign of x and are floats. ```python >>> import math >>> math.modf(10.5) (0.5, 10.0) >>> math.modf(-10.5) (-0.5, -10.0) ```
Vladimir reopened this issue 2023-05-02 20:40:03 +02:00
Blender Bot added
Status
Needs Triage
and removed
Status
Archived
labels 2023-05-02 20:40:05 +02:00
Member

It's not a random value, the value is explained in the link @PratikPB2123 gave, this definition of fract is quite common in shading languages ie opengl

You get similar behavior in pythons divmod function

>>> divmod(-12.56, 1.0)
(-13.0, 0.4399999999999995)

This is working as designed, not a bug

It's not a random value, the value is explained in the link @PratikPB2123 gave, this definition of fract is quite common in shading languages ie [opengl](https://registry.khronos.org/OpenGL-Refpages/gl4/html/fract.xhtml) You get similar behavior in pythons `divmod` function ``` >>> divmod(-12.56, 1.0) (-13.0, 0.4399999999999995) ``` This is working as designed, not a bug
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-05-02 21:04:32 +02:00
Author

divmod(-12.56, 1.0)
(-13.0, 0.4399999999999995)

This is working as designed, not a bug

Here - yes, as designed because div is division but not fraction:

divmod Description:
Returns quotient and remainder after a division of two numbers.
https://python-reference.readthedocs.io/en/latest/docs/functions/divmod.html

Math.Fraction in Blender has confuse name and also description in docs:

Fraction:
Returns the fractional part of the value.

> >>> divmod(-12.56, 1.0) > (-13.0, 0.4399999999999995) > > > This is working as designed, not a bug Here - yes, as designed because div is division but not fraction: **divmod** Description: Returns quotient and remainder **after a division of two numbers**. https://python-reference.readthedocs.io/en/latest/docs/functions/divmod.html Math.Fraction in Blender has confuse name and also description in docs: >Fraction: > Returns the fractional part of the value.
Vladimir reopened this issue 2023-05-02 21:36:20 +02:00
Blender Bot added
Status
Needs Triage
and removed
Status
Archived
labels 2023-05-02 21:36:21 +02:00

image

![image](/attachments/8a2f6320-6222-42b1-8d46-b4a8f23249aa)
9.5 KiB
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-05-02 21:42:23 +02:00
Author

I followed that link, nothing understand, only it is stated that the graph is not symmetrical. Moreover, the graph is also not symmetrical in the positive direction, and not only in the negative! That is, it turns out that the Fraction can return strange numbers even with positive input values? o_O

Blender help will be corrected? Need correct description

I followed that link, nothing understand, only it is stated that the graph is not symmetrical. Moreover, the graph is also not symmetrical in the positive direction, and not only in the negative! That is, it turns out that the Fraction can return strange numbers even with positive input values? o_O Blender help will be corrected? Need correct description

I'm still not sure about the substance of the report. This is a normal, old, function. Graphic programming is based on how it works, like noise or texture. This is a very basic thing. And it's definitely not a bug.

I'm still not sure about the substance of the report. This is a normal, old, function. Graphic programming is based on how it works, like noise or texture. This is a very basic thing. And it's definitely not a bug.
Author

Thanks for all, guys! :) Sorry... I now understand! :) This link helped me:

https://www.cuemath.com/calculus/fractional-part-function/

i will know now

Thanks for all, guys! :) Sorry... I now understand! :) This link helped me: https://www.cuemath.com/calculus/fractional-part-function/ i will know now
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#107518
No description provided.