Confusing truncate to 1 digit explanation

Hi,

There is an explanation that uses this in $project stage to truncate to 1 digit:

  {
    $project: {
      thing: {
        $divide: [{ $trunc: { $multiply: ["$thing", 10] } }, 10]
      }
    }
  },

I don’t quite follow. Why?
This is what I did which led to same results:

{
  $project: { thing: { $trunc: ["$thing", 1] } }
}

Am I missing something? Doesn’t $trunc: [<field>, <places>] do exactly the same? :thinking:

Hi,

You’re correct, but this is because the course is getting old. By the time it was recorded $trunc, 3.6 didn’t have the same definition. That’s new in $trunc 4.2

If it’s not clarified in the footnotes, it should probably be.

Just in case this is useful, I’m calling @Sonali_Mamgain :slight_smile:

2 Likes

Oh, nice. I didn’t realized that. I do agree that a footnote would be useful.

1 Like

Thanks @Santiago_Miranda for highlighting this!!

We are working on revamping this course content and will make sure all the user feedback is addressed for an improved learning experience.

Kind Regards,
Sonali

2 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.