Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Log long double value

I am currently working with large numbers such as __int64 and long doubles and im fairly new to unreal myself. I have been spending hours trying to figure out how i can print long doubles as i need to check that all my calculations are correct but this is becoming an issue as from what i can tell UE_LOG does not support Long Doubles only floats.

In standard c++ this won't be an issue as i can just use printf like

printf("%lg\n", pow(5.67 * 10,-8));

and that works fine but when i use %lg in UE_LOG like this

UE_LOG(YourInit, Warning, TEXT("test = %lg"), pow(5.67 * 10,-8));

It won't compile.

Is there a way i can log long doubles within unreal or atleast see the output from printf?

Product Version: UE 4.13
more ▼

asked Oct 21 '16 at 12:04 AM in C++ Programming

avatar image

1 1 1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

You could convert the long to a std::string, convert that to FString, and then send that to the log:

 char Buffer[100];
 snprintf(Buffer, sizeof(Buffer), "test = %lg", pow(5.67 * 10, -8));
 std::string StdMessage = Buffer;
 FString LogMessage(StdMessage.str());
 UE_LOG(YourInit, Warning, TEXT("%s"), *LogMessage);

That gave me: "test = 9.36129e-15" in my log.

I don't know if there's a more direct route, but it works.

more ▼

answered Oct 21 '16 at 03:22 AM

avatar image

1.7k 43 13 61

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question