# Force scientific notation in Blender GUI

I have an addon in development, and create various meshes in it. I have several physically based parameters, that are often extremely small, but make sense in the context they are. I have in my GUI class, for example:

poly_0: FloatProperty(
name="POLY_0",
description="Some description...",
default=1.26587922531743e-16,
min=-1000.0,
max=+1000.0,
)


In the GUI, I would like to force this Float member to always be displayed in scientific notation, and always with some set precision (number of digits). Looking in the API docs, I cant seem to find this option.

• AFAIK setting the precision argument to 6 (max) is the only thing you can do... – brockmann Dec 8 '20 at 12:39
• @brockmann, very valuable information. I thought the precision of FloatProperty was per default 64bit, as with python floats. When you wrote 6 as display-preciscion max, I looked up the documentation. It does state that it is single precision link. This puts my addon development in trouble. I am going to ask a new question about this instead – Stefan Karlsson Dec 22 '20 at 11:57

Make a Scientific Notation Property Group.

As a workaround could set up a property group to handle scientific notation. Restricted to the significant digits of the float property, but allows to set the the power.

import bpy
from bpy.props import FloatProperty, IntProperty, PointerProperty
from bpy.types import PropertyGroup

class ScientificNotation(PropertyGroup):
def get_num(self):
return self.number *  pow(10, self.power)
number : FloatProperty(min=-10, max=10)
power : IntProperty()
value = property(get_num)

bpy.utils.register_class(ScientificNotation)
bpy.types.Scene.foo = PointerProperty(type=ScientificNotation)


Layout with both number and power to set. Use the value property in calculation. Could use a string property for the number, to get more sig digits.

Example of use in python console.

>>> C.scene.foo.number = 6.62607004
>>> C.scene.foo.power = -34
>>> C.scene.foo.value
6.626070022583007e-34