And for completeness, the third practical option listed in @erAck 's answer. We place in the document (for example, using APSO) the utils.py module containing the functions from @karolus 's answer.
To the Standard library, the Basic module:
Option Explicit
Global oScriptDTH As Object
' Returns a string of 16 hexadecimal digits corresponding to
' the internal representation of double.
Function DoubleToHex(ByVal d As Double) As String
If oScriptDTH Is Nothing Then
oScriptDTH = ThisComponent.getScriptProvider.getScript("vnd.sun.star.script:utils.py$doub_hex?language=Python&location=document")
End If
DoubleToHex=oScriptDTH.invoke(Array(d), array(), array())
End Function