# \[C2397\] conversion from 'T' to 'float' requires a narrowing conversion

**URL:** <https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215>\
**Category:** C++\
**Tags:** Class, unreal-engine, UE5-0, question, CPP\
**Created:** [March 23, 2022, 4:41pm UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215 "2022-03-23T16:41:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![n00b\_013](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/n00b_013/32/631138_2.png) [@n00b\_013](https://forums.unrealengine.com/u/n00b_013)\
**Post date:** [March 23, 2022, 4:41pm UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215/1 "2022-03-23T16:41:46Z")

</div>

Hi all,

I hope you are all being safe and well during these crazy COVID times, looking forward to the full release of UE5! Though, at the moment I’m creating a new character controller for UE5 using C++ and all the sudden I’m running into an issue, that I did not have before in UE4.26/ UE4.27.

I’m getting the following C2397 error on the line containing :

```auto
	const float Target{ Delta.Yaw / Deltatime };

```

Error Log:

```auto
  ShooterAnimInstance.cpp(153): [C2397] conversion from 'T' to 'float' requires a narrowing conversion
  ShooterAnimInstance.cpp(153): [C2397] conversion from 'T' to 'const float' requires a narrowing conversion

```

Full snippet of the function.

```auto
void UShooterAnimInstance::Lean(float Deltatime)
{
	if (ShooterCharacter == nullptr) return;
	CharacterRotationLastFrame = CharacterRotation;
	CharacterRotation = ShooterCharacter->GetActorRotation();

	const FRotator Delta{ UKismetMathLibrary::NormalizedDeltaRotator(CharacterRotation, CharacterRotationLastFrame) };

	const float Target{ Delta.Yaw / Deltatime };
	const float Interp{FMath::FInterpTo(YawDelta, Target, Deltatime, 6.f)};
	YawDelta = FMath::Clamp(Interp, -90.f, 90.f);
}

```

Is there a major change in compiling UE5, compared to version 4? As this same code was running perfectly before… Or is there something I’m missing in the declaration of the variables…

Kind regards,

n00b

---

<div class="post-metadata">

**Author:** ![TelesphorosGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/telesphorosgames/32/924355_2.png) [@TelesphorosGames](https://forums.unrealengine.com/u/TelesphorosGames)\
**Post date:** [April 5, 2022, 7:36pm UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215/2 "2022-04-05T19:36:06Z")

</div>

I guess another thing you can do is use “=” to trigger an implicit conversion when initializing with {} , cheers!

---

<div class="post-metadata">

**Author:** ![TelesphorosGames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/telesphorosgames/32/924355_2.png) [@TelesphorosGames](https://forums.unrealengine.com/u/TelesphorosGames)\
**Post date:** [April 5, 2022, 7:36pm UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215/3 "2022-04-05T19:36:28Z")

</div>

Hey friend - just had the same issue. Was able to compile by changing all of the floats in question to doubles. just replace the word float with the word double on all the lines where the error is being thrown.

---

<div class="post-metadata">

**Author:** ![n00b\_013](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/n00b_013/32/631138_2.png) [@n00b\_013](https://forums.unrealengine.com/u/n00b_013)\
**Post date:** [April 5, 2022, 8:16pm UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215/4 "2022-04-05T20:16:35Z")

</div>

Thanks to both of you! Going to try this out when i get home! Will let you know the outcome 😊👍🏻

---

<div class="post-metadata">

**Author:** ![MonsterNice](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MonsterNice](https://forums.unrealengine.com/u/MonsterNice)\
**Post date:** [April 22, 2022, 5:30am UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215/5 "2022-04-22T05:30:02Z")

</div>

const float Interp{FMath::FInterpTo(float(YawDelta), float(Target), float(Deltatime), 6.f)};  
or  
const double Interp{FMath::FInterpTo(YawDelta, Target, Deltatime, 6.f)};

---

<div class="post-metadata">

**Author:** ![DAGEZHILIAO1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DAGEZHILIAO1](https://forums.unrealengine.com/u/DAGEZHILIAO1)\
**Post date:** [September 6, 2023, 7:13am UTC](https://forums.unrealengine.com/t/c2397-conversion-from-t-to-float-requires-a-narrowing-conversion/509215/6 "2023-09-06T07:13:56Z")

</div>

Try to use:  
const float Target { float(Delta.Yaw) / DeltaTime };
