Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

396
Views
Why is float.IsFinite “not defined” in Unity?

When I use float.IsFinite(float f) in a C# shell, I have no problems. However, when I use it in the context of Unity, I get an error alleging that it is not defined:

error CS0117: 'float' does not contain a definition for 'IsFinite'

Here is the relevent code:

public static bool IsFinite(Unit u) => float.IsFinite(u.blocks);

Unit is a struct in which I wrote the above line.

My question is: why does this error appear and how can I fix it?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

float.IsFinite exists in .NET 5, .NET Standard 2.1 and .NET Core 2.1. However Unity supports neither of those frameworks, just .NET Standard 2.0. This is why you cannot use the function here.

However it´s easy to create a workaround for the lack of that function:

public static bool IsFinite(Unit u) => !float.IsInfinity(u.blocks)

There´s an angoing discussion at Unitity support forum about .NET 5

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!