在javascript

时间:2019-05-21 09:10:16

标签: javascript

function covertToIPv6(IP)
{
       var ip = "";
       ip = ((IP >> 112 ) & 0xFFFF) + ":" + ((IP >> 96 ) & 0xFFFF) + ":" + ((IP 
         >> 80 ) & 0xFFFF) + ":" +((IP >> 64 ) & 0xFFFF) + ":" + ((IP >> 48 ) & 
         0xFFFF) + ":" + ((IP >> 32 ) & 0xFFFF) + ":" + ((IP >> 16 ) & 0xFFFF) + 
       ":"+( IP & 0xFFFF);

       console.log(ip);
}

covertToIPv6(63802943797675961899382738893456539648);

嗨,我正在尝试将大整数或十进制数字转换为有效的IPv6 address 我已经尝试了以下功能。

但这给出了所有零集

covertToIPv6(63802943797675961899382738893456539648);
  

回答:0:0:0:0:0:0:0:0

1 个答案:

答案 0 :(得分:0)

如果您确实不能使用at MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection) at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) at MySql.Data.Entity.MySqlManifestTokenResolver.ResolveManifestToken(DbConnection connection) at System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() at System.Data.Entity.Internal.Linq.InternalSet`1.ExecuteSqlQueryAsync(String sql, Boolean asNoTracking, Nullable`1 streaming, Object[] parameters) at System.Data.Entity.Internal.InternalSqlSetQuery.GetAsyncEnumerator() at System.Data.Entity.Infrastructure.DbRawSqlQuery`1.System.Data.Entity.Infrastructure.IDbAsyncEnumerable<TElement>.GetAsyncEnumerator() at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ForEachAsync[T](IDbAsyncEnumerable`1 source, Action`1 action, CancellationToken cancellationToken) at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ToListAsync[T](IDbAsyncEnumerable`1 source, CancellationToken cancellationToken) at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.ToListAsync[T](IDbAsyncEnumerable`1 source) at System.Data.Entity.Infrastructure.DbRawSqlQuery`1.ToListAsync() at m2a.Repositories.Repository.<GetCallbacks>d__2.MoveNext() in C:\Users\JNyingi\source\repos\m2a\Repositories\Repository.cs:line 38 或字符串表示形式,则此功能可以将大整数重新转换为IPv6地址。但是,整数必须使用字符串表示形式才能起作用。

BigInt