Skip to main content

Wise ones,

Is there a way to prevent UDOWrite converting large numbers into scientific format?

For example:

PROGRAM temp

$INCLUDE UNIVERSE.INCLUDE UDO.H

Value = 1234567890.123
Ok = UDOCreate(UDO_OBJECT,hObject)
Ok = UDOSetProperty(hObject,'large', Value)
Ok = UDOWrite(hObject, UDOFORMAT_JSON, JSON)
Crt JSON

STOP

{
        "large":        1.234568e+09
}

I can't make it a string as that will fail the JSON schema validation.

Integral numbers are not affected by this so I could INT() it, but that's not really a solution.

Thanks

Wise ones,

Is there a way to prevent UDOWrite converting large numbers into scientific format?

For example:

PROGRAM temp

$INCLUDE UNIVERSE.INCLUDE UDO.H

Value = 1234567890.123
Ok = UDOCreate(UDO_OBJECT,hObject)
Ok = UDOSetProperty(hObject,'large', Value)
Ok = UDOWrite(hObject, UDOFORMAT_JSON, JSON)
Crt JSON

STOP

{
        "large":        1.234568e+09
}

I can't make it a string as that will fail the JSON schema validation.

Integral numbers are not affected by this so I could INT() it, but that's not really a solution.

Thanks

Brian,

Yes,  there was a fix a while back to handle the large numbers, but that was related to large integers, and I understand why that would not work for you.

While I can think of some options post creation of JSON, that would come with its own issues and overhead.

I suggest you open a support ticket.  


Wise ones,

Is there a way to prevent UDOWrite converting large numbers into scientific format?

For example:

PROGRAM temp

$INCLUDE UNIVERSE.INCLUDE UDO.H

Value = 1234567890.123
Ok = UDOCreate(UDO_OBJECT,hObject)
Ok = UDOSetProperty(hObject,'large', Value)
Ok = UDOWrite(hObject, UDOFORMAT_JSON, JSON)
Crt JSON

STOP

{
        "large":        1.234568e+09
}

I can't make it a string as that will fail the JSON schema validation.

Integral numbers are not affected by this so I could INT() it, but that's not really a solution.

Thanks

Regardless of the conversion to scientific notation, something is very wrong because it is losing precision.


Wise ones,

Is there a way to prevent UDOWrite converting large numbers into scientific format?

For example:

PROGRAM temp

$INCLUDE UNIVERSE.INCLUDE UDO.H

Value = 1234567890.123
Ok = UDOCreate(UDO_OBJECT,hObject)
Ok = UDOSetProperty(hObject,'large', Value)
Ok = UDOWrite(hObject, UDOFORMAT_JSON, JSON)
Crt JSON

STOP

{
        "large":        1.234568e+09
}

I can't make it a string as that will fail the JSON schema validation.

Integral numbers are not affected by this so I could INT() it, but that's not really a solution.

Thanks

Since UDO does not fully support JSON types, I make everything a string and covert it into JavaScript 

$INCLUDE UNIVERSE.INCLUDE UDO.H

Value = "1234567890.123"

Ok = UDOCreate(UDO_OBJECT,hObject)

Ok = UDOSetProperty(hObject,'large', Value)

Ok = UDOWrite(hObject, UDOFORMAT_JSON, JSON)

Crt JSON

STOP

>RUN BP DOUG11
{
"large": "1234567890.123"
}
Last auto-saved at: 06-06-2025 15:09